security->isGranted('ROLE_USER')) { throw new AccessDeniedException('Access denied: ROLE_USER required.'); } $project = $this->projectRepository->find($id); if (null === $project) { throw new InvalidArgumentException(sprintf('Project with ID %d not found.', $id)); } if (null !== $name) { $project->setName($name); } if (null !== $code) { $project->setCode($code); } if (null !== $description) { $project->setDescription($description); } if (null !== $color) { $project->setColor($color); } if (null !== $clientId) { $client = $this->clientRepository->find($clientId); if (null === $client) { throw new InvalidArgumentException(sprintf('Client with ID %d not found.', $clientId)); } $project->setClient($client); } if (null !== $archived) { $project->setArchived($archived); } $this->entityManager->flush(); return json_encode(Serializer::project($project)); } }