security->isGranted('ROLE_USER')) { throw new AccessDeniedException('Access denied: ROLE_USER required.'); } $project = $this->projectRepository->find($projectId); if (null === $project) { throw new InvalidArgumentException(sprintf('Project with ID %d not found.', $projectId)); } $group = new TaskGroup(); $group->setProject($project); $group->setTitle($title); if (null !== $description) { $group->setDescription($description); } if (null !== $color) { $group->setColor($color); } $this->entityManager->persist($group); $this->entityManager->flush(); return json_encode(Serializer::groupFull($group)); } }