/** * Publishes an entry as an article * NOTE: Partially finished and partially tested, got stuck at Article Entity * TODO: Fix this correctly and replace publishLegacy() with this * * @param \NewscoopIngestPluginBundleEntityFeedEntry $entry Entry to be published */ protected function publishNew(\Newscoop\IngestPluginBundle\Entity\Feed\Entry $entry) { if ($this->getArticle($entry) !== null) { // Update article $this->update($entry); } else { $publication = $entry->getFeed()->getPublication(); $latestIssue = $this->em->getRepository('\\Newscoop\\Entity\\Issue')->findOneBy(array('publication' => $publication, 'language' => $entry->getLanguage(), 'workflowStatus' => 'Y'), array('number' => 'DESC')); $articleType = $this->em->getRepository('\\Newscoop\\Entity\\ArticleType')->findOneBy(array('name', 'Newswire')); // Map data $mappingArray = $this->atcf->getArticleTypeMapping(); $dataArray = array(); foreach ($mappingArray as $fieldID => $method) { $dataArray[$fieldID] = $entry->{$method}(); } // Create new Article $article = new \Newscoop\Entity\Article(0, $entry->getLanguage()); // Set title and typeData $article->author($entry->getTitle(), $dataArray); // Main article settings $article->setType($articleType)->setPublication($publication)->setIssue($latestIssue)->setSection($entry->getSection())->setKeywords($entry->getKeywords())->setCommentsEnabled(1); $this->setArticleAuthors($article, $entry); $this->setArticleImages($article, $entry); // Publish article $article->publish(); // Save changes $this->em->persist($article); $entry->setArticleId($article->getNumber()); $this->em->persist($entry); $this->em->flush(); } }
/** * Remove an Article from the Snippet * * @param Article $article the Article to remove * * @return Newscoop\Entity\Snippet */ public function removeArticle(Article $article) { if ($this->articles->contains($article)) { $article->removeSnippet($this); $this->articles->removeElement($article); } return $this; }
/** * @param string $webcode * @param Newscoop\Entity\Article $article */ public function __construct($webcode, $article) { $this->webcode = (string) $webcode; $this->article = $article; $article->setWebcode($this); }