addTopic() public method

Add Topic to the Article.
public addTopic ( Topic $topic ) : boolean
$topic Newscoop\NewscoopBundle\Entity\Topic the Topic to attach
return boolean
Example #1
0
 /**
  * Adds topic to the article.
  *
  * @param Topic   $topic   Topic object
  * @param Article $article Article object
  *
  * @return bool
  */
 protected function attachTopicToArticle(Topic $topic, Article $article)
 {
     $result = $article->addTopic($topic);
     if ($result) {
         $this->em->flush();
         $this->dispatcher->dispatch('article-topic.attach', new GenericEvent($this, $this->getLogArray($topic, $article)));
     }
     return $result;
 }