. */ namespace Chill\DocStoreBundle\Security\Authorization; use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\ProvideRoleInterface; /** * */ class PersonDocumentVoter extends AbstractChillVoter implements ProvideRoleInterface { const CREATE = 'CHILL_PERSON_DOCUMENT_CREATE'; const SEE = 'CHILL_PERSON_DOCUMENT_SEE'; const SEE_DETAILS = 'CHILL_PERSON_DOCUMENT_SEE_DETAILS'; const UPDATE = 'CHILL_PERSON_DOCUMENT_UPDATE'; const DELETE = 'CHILL_PERSON_DOCUMENT_DELETE'; /** * * @var AuthorizationHelper */ protected $helper; public function __construct(AuthorizationHelper $helper) { $this->helper = $helper; } protected function getSupportedAttributes() { return array(self::CREATE, self::SEE, self::UPDATE, self::DELETE, self::SEE_DETAILS); } protected function getSupportedClasses() { return array('Chill\DocStoreBundle\Entity\PersonDocument'); } protected function isGranted($attribute, $report, $user = null) { if (! $user instanceof \Chill\MainBundle\Entity\User){ return false; } return $this->helper->userHasAccess($user, $report, $attribute); } public function getRoles() { return $this->getSupportedAttributes(); } public function getRolesWithoutScope() { return array(); } public function getRolesWithHierarchy() { return ['PersonDocument' => $this->getRoles() ]; } }