security->isGranted('ROLE_ADMIN')) { throw new AccessDeniedException('Access denied: ROLE_ADMIN required.'); } $contact = $this->contactRepository->findById($id); if (null === $contact) { throw new InvalidArgumentException(sprintf('Contact with ID %d not found.', $id)); } return json_encode(Serializer::contact($contact)); } }