Example #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 testCreateThread()
 {
     $manager = new ThreadManager($this->em, $this->class);
     $result = $manager->createThread();
     $this->assertInstanceOf('FOS\\CommentBundle\\Model\\ThreadInterface', $result);
 }