public function setArticleAuthors($articleAuthors) { $this->articleAuthors = $articleAuthors; }
/** * Set authors for article, if author doesn't exist it gets created * * @param \Newscoop\Entity\Article $article Article * @param \Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry Entity */ protected function setArticleAuthors(\Newscoop\Entity\Article $article, \Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry) { $repository = $this->em->getRepository('\\Newscoop\\Entity\\Author'); $doctrineCollection = new \Doctrine\Common\Collections\ArrayCollection(); $authors = $entry->getAuthors(); if (count($authors) > 0) { foreach ($authors as $author) { $authorEntity = $repository->findBy(array('first_name' => $author['firstname'], 'last_name' => $author['lastname'])); if ($authorEntity === null) { $authorEntity = new \Newscoop\Entity\Author($author['firstname'], $author['lastname']); } $doctrineCollection->add($authorEntity); } $article->setArticleAuthors($doctrineCollection); } }