public function create(Topic $topic) { if (!($category = $topic->getCategory())) { throw new LogicException('Each topic must have a category'); } $category->incrementNumTopics(); $category->setLastTopic($topic); }
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); }
public function getTopicNumPages(Topic $topic) { return ceil($topic->getNumPosts() / $this->nbPostsPerPage); }