security->getUser(); if (!$user instanceof User) { throw new AccessDeniedHttpException('Authentication required.'); } // Réservé aux profils "Sites" (ni admin, ni self). if (in_array('ROLE_ADMIN', $user->getRoles(), true) || in_array('ROLE_SELF', $user->getRoles(), true)) { throw new AccessDeniedHttpException('Only site managers can update site validation.'); } $siteId = $data->getEmployee()?->getSite()?->getId(); if (!$siteId) { throw new AccessDeniedHttpException('Employee site is required.'); } $allowedSiteIds = $this->employeeScopeService->getAllowedSiteIds($user); if (!in_array($siteId, $allowedSiteIds, true)) { throw new AccessDeniedHttpException('Employee is outside your site scope.'); } $this->entityManager->flush(); return $data; } }