Пример #1
0
 /**
  * @param string $attribute
  * @param CourseInterface $course
  * @param TokenInterface $token
  * @return bool
  */
 protected function voteOnAttribute($attribute, $course, TokenInterface $token)
 {
     $user = $token->getUser();
     if (!$user instanceof UserInterface) {
         return false;
     }
     switch ($attribute) {
         case self::VIEW:
             return $this->isViewGranted($course->getId(), $course->getSchool()->getId(), $user);
             break;
         case self::CREATE:
         case self::EDIT:
         case self::DELETE:
             return $this->isWriteGranted($course->getId(), $course->getSchool()->getId(), $user);
             break;
     }
     return false;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function userHasWritePermissionToCourse(UserInterface $user, CourseInterface $course)
 {
     return $this->userHasPermission($user, self::CAN_WRITE, 'course', $course->getId());
 }