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