/** * 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); }
/** * 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); }