helper = $helper; } protected function supports($attribute, $subject) { return $subject instanceof AccompanyingPeriod; } protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { if (!$token->getUser() instanceof User) { return false; } // TODO take scopes into account if (count($subject->getPersons()) === 0) { return true; } foreach ($subject->getPersons() as $person) { // give access as soon as on center is reachable if ($this->helper->userHasAccess($token->getUser(), $person->getCenter(), $attribute)) { return true; } return false; } } private function getAttributes() { return [ self::SEE ]; } public function getRoles() { return $this->getAttributes(); } public function getRolesWithoutScope() { return []; } public function getRolesWithHierarchy() { return [ 'Person' => $this->getRoles() ]; } }