Пример #1
0
 /**
  * @param string $attribute
  * @param LockableEntityInterface $lockable
  * @param UserInterface|null $user
  * @return bool
  */
 protected function isGranted($attribute, $lockable, $user = null)
 {
     if (self::MODIFY === $attribute) {
         return !$lockable->isLocked();
     }
     return false;
 }
Пример #2
0
 /**
  * @param string $attribute
  * @param LockableEntityInterface $lockable
  * @param TokenInterface $token
  * @return bool
  */
 protected function voteOnAttribute($attribute, $lockable, TokenInterface $token)
 {
     if (self::UNLOCK === $attribute) {
         $user = $token->getUser();
         if (!$user instanceof UserInterface) {
             return false;
         }
         return $user->hasRole(['Developer']);
     }
     if (self::MODIFY === $attribute) {
         return !$lockable->isLocked();
     }
     return false;
 }