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([ 'id' => $project->getId(), 'code' => $project->getCode(), 'name' => $project->getName(), 'description' => $project->getDescription(), 'color' => $project->getColor(), 'client' => $project->getClient() ? [ 'id' => $project->getClient()->getId(), 'name' => $project->getClient()->getName(), ] : null, 'archived' => $project->isArchived(), ]); } }