security->isGranted('ROLE_ADMIN')) { throw new AccessDeniedException('Access denied: ROLE_ADMIN required.'); } $client = $this->clientRepository->findById($id); if (null === $client) { throw new InvalidArgumentException(sprintf('Client with ID %d not found.', $id)); } if (null !== $name) { $client->setName($name); } if (null !== $email) { $client->setEmail($email); } if (null !== $phone) { $client->setPhone($phone); } if (null !== $website) { $client->setWebsite($website); } $this->entityManager->flush(); return json_encode(Serializer::client($client)); } }