authorizationHelper = $authorizationHelper; $this->centerResolverDispatcher = $centerResolverDispatcher; $this->configuration = $configuration; } public function supports($attribute, $subject): bool { foreach ($this->configuration as [$attributes, $subj]) { if (null === $subj) { if (null === $subject && in_array($attribute, $attributes, true)) { return true; } } elseif ($subject instanceof $subj) { return in_array($attribute, $attributes, true); } } return false; } public function voteOnAttribute($attribute, $subject, $token): bool { if (!$token->getUser() instanceof User) { return false; } if (null === $subject) { return [] !== $this->authorizationHelper->getReachableCenters($token->getUser(), $attribute, null); } return $this->authorizationHelper->userHasAccess( $token->getUser(), $subject, $attribute ); } }