authorizationHelper = $authorizationHelper; } public function getRoles(): array { return [ self::CREATE, self::UPDATE, self::SHOW, ]; } public function getRolesWithHierarchy(): array { return [ 'Third party' => $this->getRoles(), ]; } public function getRolesWithoutScope(): array { return $this->getRoles(); } protected function supports($attribute, $subject) { if ($subject instanceof ThirdParty) { return \in_array($attribute, $this->getRoles(), true); } if (null === $subject) { return self::CREATE === $attribute || self::SHOW === $attribute; } return false; } /** * @param string $attribute * @param ThirdParty|null $subject */ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { return true; $user = $token->getUser(); if (!$user instanceof User) { return false; } return true; $centers = $this->authorizationHelper ->getReachableCenters($user, $attribute); if (null === $subject) { return \count($centers) > 0; } if ($subject instanceof ThirdParty) { return \count(\array_intersect($centers, $subject->getCenters()->toArray())) > 0; } return false; } }