コード例 #1
0
ファイル: CommentService.php プロジェクト: cobase/cobase
 /**
  * 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);
     }
 }
コード例 #2
0
 public function testCreateThread()
 {
     $manager = new ThreadManager($this->em, $this->class);
     $result = $manager->createThread();
     $this->assertInstanceOf('FOS\\CommentBundle\\Model\\ThreadInterface', $result);
 }
コード例 #3
0
 /**
  * Constructor
  *
  * @param CommentManager           $commentManager
  * @param EventDispatcherInterface $dispatcher
  * @param EntityManager            $em
  * @param string                   $class
  */
 public function __construct(CommentManager $commentManager, EventDispatcherInterface $dispatcher, EntityManager $em, $class)
 {
     $this->commentManager = $commentManager;
     parent::__construct($dispatcher, $em, $class);
 }