security->isGranted('ROLE_USER')) { throw new AccessDeniedException('Access denied: ROLE_USER required.'); } $group = $this->taskGroupRepository->find($id); if (null === $group) { throw new InvalidArgumentException(sprintf('TaskGroup with ID %d not found.', $id)); } $title = $group->getTitle(); $this->entityManager->remove($group); $this->entityManager->flush(); return json_encode(['success' => true, 'message' => sprintf('Group "%s" deleted.', $title)]); } }