security->isGranted('ROLE_ADMIN')) { throw new AccessDeniedException('Access denied: ROLE_ADMIN required.'); } $prestataire = $this->prestataireRepository->findById($id); if (null === $prestataire) { throw new InvalidArgumentException(sprintf('Prestataire with ID %d not found.', $id)); } $name = $prestataire->getName(); $this->entityManager->remove($prestataire); $this->entityManager->flush(); return json_encode(['success' => true, 'message' => sprintf('Prestataire "%s" deleted.', $name)]); } }