security = $security; } protected function supports($attribute, $subject): bool { return in_array($attribute, self::ALL, true) && $subject instanceof CalendarDoc; } /** * @param CalendarDoc $subject * @param mixed $attribute */ protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool { switch ($attribute) { case self::EDIT: return $this->security->isGranted(CalendarVoter::EDIT, $subject->getCalendar()); case self::SEE: return $this->security->isGranted(CalendarVoter::SEE, $subject->getCalendar()); default: throw new UnexpectedValueException('Attribute not supported: ' . $attribute); } } }