Ejemplo n.º 1
0
 /**
  * @param CourseInterface $course
  * @param null $limit
  * @param null $offset
  * @return mixed
  */
 public function getByCourse(CourseInterface $course, $limit = null, $offset = null)
 {
     $qb = $this->createQueryBuilder('cm')->where('cm.course = :course_id')->setParameter('course_id', $course->getId(), TYPE::INTEGER);
     if (is_int($limit)) {
         $qb->setMaxResults($limit);
     }
     if (is_int($offset)) {
         $qb->setFirstResult($offset);
     }
     return $qb->getQuery()->getResult();
 }
Ejemplo n.º 2
0
 /**
  * Checks to see if a publisher has permission to perform an action
  *
  * @param CourseInterface $entity
  * @param UserEntityInterface $user
  * @param $action
  * @return bool
  */
 protected function isPublisherActionAllowed($entity, UserEntityInterface $user, $action)
 {
     return $user->getId() === $entity->getAuthor()->getId();
 }
Ejemplo n.º 3
0
 /**
  * @param CourseInterface $course
  * @param $position
  * @return mixed
  */
 public function getChapterByCourseAndPosition(CourseInterface $course, $position)
 {
     $qb = $this->createQueryBuilder('ch')->where('ch.course = :course_id')->andWhere('ch.position = :position')->setParameter('position', $position, Type::INTEGER)->setParameter('course_id', $course->getId(), TYPE::INTEGER);
     return $qb->getQuery()->getOneOrNullResult();
 }