security = $security; } protected function supports($attribute, $subject) { return $subject instanceof AccompanyingPeriodWorkEvaluation && in_array($attribute, self::ALL, true); } /** * @param string $attribute * @param AccompanyingPeriodWorkEvaluation $subject */ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { switch ($attribute) { case self::STATS: return $this->security->isGranted(AccompanyingPeriodWorkVoter::STATS, $subject); case self::SEE: return $this->security->isGranted(AccompanyingPeriodWorkVoter::SEE, $subject->getAccompanyingPeriodWork()); default: throw new UnexpectedValueException("attribute {$attribute} is not supported"); } } }