Exemple #1
0
 /**
  * Initialize comment threads for each post, create new thread if none exists.
  *
  * @param array $posts
  */
 public function initializeCommentThreads(array $posts)
 {
     foreach ($posts as $post) {
         $thread = $this->commentThreadManager->findThreadById($post->getId());
         if (!$thread) {
             $thread = $this->commentThreadManager->createThread($post->getId());
             $postUrl = $this->router->generate('CobaseAppBundle_post_view', array('postId' => $post->getId(), 'groupId' => $post->getGroup()->getShortUrl()), true);
             $permalink = urldecode($postUrl);
             $thread->setPermalink($permalink);
             $this->commentThreadManager->saveThread($thread);
         }
         $post->setCommentThread($thread);
     }
 }
 public function testAddThread()
 {
     $thread = $this->getMock('FOS\\CommentBundle\\Model\\ThreadInterface');
     $this->em->expects($this->once())->method('persist')->with($thread);
     $this->em->expects($this->once())->method('flush');
     $manager = new ThreadManager($this->dispatcher, $this->em, $this->class);
     $manager->saveThread($thread);
 }