getUser(); // if the user is anonymous, do not grant access if (!$user instanceof UserInterface) { return false; } if($subject->getOrganizationId() !== $user->getOrganization()->getId()){ return false; } return $this->security->isGranted('ROLE_COTISATION') && $this->networkUtils->isCMFAndActiveNow($user->getOrganization()); } }