Ejemplo n.º 1
0
 public function create(Topic $topic)
 {
     if (!($category = $topic->getCategory())) {
         throw new LogicException('Each topic must have a category');
     }
     $category->incrementNumTopics();
     $category->setLastTopic($topic);
 }
Ejemplo n.º 2
0
 public function remove(Topic $topic)
 {
     $category = $topic->getCategory();
     foreach ($this->getTopicPosts($topic) as $post) {
         $this->objectManager->remove($post);
     }
     $this->objectManager->remove($topic);
     // Must flush because the category updater will fetch topics from DB
     $this->objectManager->flush();
     $this->categoryUpdater->update($category);
 }
Ejemplo n.º 3
0
 public function getTopicNumPages(Topic $topic)
 {
     return ceil($topic->getNumPosts() / $this->nbPostsPerPage);
 }