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)); } $payload = Serializer::client($client); $payload['contacts'] = array_map( fn ($c) => Serializer::contact($c), $this->contactRepository->findBy(['client' => $client], ['lastName' => 'ASC']) ); $payload['addresses'] = array_map( fn ($a) => Serializer::address($a), $this->addressRepository->findBy(['client' => $client], ['id' => 'ASC']) ); $payload['reports'] = array_map( fn ($r) => Serializer::commercialReport($r), $this->reportRepository->findBy(['client' => $client], ['occurredAt' => 'DESC']) ); return json_encode($payload); } }