Пример #1
0
 public function remove(Post $post)
 {
     $topic = $post->getTopic();
     if (1 === $post->getNumber()) {
         throw new LogicException('You shall not remove the first topic post. Remove the topic instead');
     }
     $this->objectManager->remove($post);
     // Must flush because the topic updater will fetch posts from DB
     $this->objectManager->flush();
     $this->topicUpdater->update($topic);
     // Must flush because the category updater will fetch topics from DB
     $this->objectManager->flush();
     $this->categoryUpdater->update($topic->getCategory());
 }
Пример #2
0
 public function urlForPost(Post $post, $absolute = false)
 {
     $topicUrl = $this->urlForTopic($post->getTopic(), $absolute);
     $topicPage = ceil($post->getNumber() / $this->nbPostsPerPage);
     return sprintf('%s?page=%d#%d', $topicUrl, $topicPage, $post->getNumber());
 }