public function getNextChapter(Chapter $chapter) { try { $qb = $this->_em->createQueryBuilder(); return $this->_em->createQueryBuilder()->add('select', 'c')->add('from', 'Icap\\LessonBundle\\Entity\\Chapter c')->innerJoin('c.lesson', ' l')->where($qb->expr()->andx($qb->expr()->gt('c.left', '?1'), $qb->expr()->eq('l.id', '?2')))->orderBy('c.left', 'ASC')->setParameter(1, $chapter->getLeft())->setParameter(2, $chapter->getLesson())->setFirstResult(0)->setMaxResults(1)->getQuery()->getSingleResult(); } catch (\Doctrine\Orm\NoResultException $e) { return; } }
public function postPersist(Chapter $chapter, LifecycleEventArgs $event) { $userPicker = $chapter->getUserPicker(); $lesson = $chapter->getLesson(); if ($userPicker !== null && count($userPicker->getUserIds()) > 0 && $lesson->getResourceNode() !== null) { $details = array('chapter' => array('lesson' => $lesson->getId(), 'chapter' => $chapter->getId(), 'title' => $chapter->getTitle()), 'resource' => array('id' => $lesson->getId(), 'name' => $lesson->getResourceNode()->getName(), 'type' => $lesson->getResourceNode()->getResourceType()->getName())); $notification = $this->notificationManager->createNotification('resource-icap_lesson-user_tagged', 'lesson', $lesson->getResourceNode()->getId(), $details); $this->notificationManager->notifyUsers($notification, $userPicker->getUserIds()); } }
/** * Copy chapter_org subchapters into provided chapter_copy * @param Chapter $chapter_org * @param Chapter $parent * @param boolean $copy_children * @param Lesson $copyName * * @return Chapter $chapter_copy */ public function copyChapter(Chapter $chapter_org, Chapter $parent, $copy_children, $copyName = null) { $chapter_copy = new Chapter(); if (!$copyName) { $copyName = $chapter_org->getTitle(); } $chapter_copy->setTitle($copyName); $chapter_copy->setText($chapter_org->getText()); $chapter_copy->setLesson($parent->getLesson()); $this->insertChapter($chapter_copy, $parent); if ($copy_children) { $this->copyChildren($chapter_org, $chapter_copy, $copy_children); } return $chapter_copy; }