/** * @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(); }
/** * 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(); }
/** * @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(); }