* @author Champs Libres */ class EventVoter extends AbstractChillVoter implements ProvideRoleInterface { const SEE = 'CHILL_EVENT_SEE'; const SEE_DETAILS = 'CHILL_EVENT_SEE_DETAILS'; const CREATE = 'CHILL_EVENT_CREATE'; const UPDATE = 'CHILL_EVENT_UPDATE'; protected $authorizationHelper; public function __construct(AuthorizationHelper $helper) { $this->authorizationHelper = $helper; } protected function getSupportedAttributes() { return array(self::SEE, self::SEE_DETAILS, self::CREATE, self::UPDATE); } protected function getSupportedClasses() { return array(Event::class); } protected function isGranted($attribute, $event, $user = null) { if (!$user instanceof User) { return false; } return $this->helper->userHasAccess($user, $event, $attribute); } public function getRoles() { return $this->getSupportedAttributes(); } public function getRolesWithoutScope() { return null; } }