Example #1
0
 /**
  * @param TutorialInterface $tutorial
  * @param null $limit
  * @param null $offset
  * @return mixed
  */
 public function getByTutorial(TutorialInterface $tutorial, $limit = null, $offset = null)
 {
     $qb = $this->createQueryBuilder('cm')->where('cm.tutorial = :tutorial_id')->setParameter('tutorial_id', $tutorial->getId(), TYPE::INTEGER);
     if (is_int($limit)) {
         $qb->setMaxResults($limit);
     }
     if (is_int($offset)) {
         $qb->setFirstResult($offset);
     }
     return $qb->getQuery()->getResult();
 }
Example #2
0
 /**
  * Checks to see if a publisher has permission to perform an action
  *
  * @param TutorialInterface $entity
  * @param UserEntityInterface $user
  * @param $action
  * @return bool
  */
 protected function isPublisherActionAllowed($entity, UserEntityInterface $user, $action)
 {
     return $user->getId() === $entity->getAuthor()->getId();
 }