/** * Write an ItemInterface into the feed * * @param \Nekland\FeedBundle\XML\XMLManager $xml * @param \Nekland\FeedBundle\Item\ItemInterface $item * @return void */ private function writeItem(XMLManager $xml, ItemInterface $item) { $nodeItem = $this->createItem($xml); $xml->addTextNode('title', $item->getFeedTitle(), $nodeItem); $xml->addTextNode('description', $item->getFeedDescription(), $nodeItem); $id = $item->getFeedId(); if (empty($id)) { throw new \InvalidArgumentException('The method « getFeedId » MUST return a not empty value.'); } $xml->addTextNode('guid', $id, $nodeItem); $xml->addTextNode('link', $this->getRoute($item), $nodeItem); $xml->addTextNode('pubDate', $item->getFeedDate()->format(\DateTime::RSS), $nodeItem); if ($this->itemHas($item, 'getFeedAuthor')) { if ($author = $this->getAuthor($item)) { $xml->addTextNode('author', $author['name'], $nodeItem); } } if ($this->itemHas($item, 'getFeedCategory')) { $xml->addTextNode('category', $item->getFeedCategory(), $nodeItem); } if ($this->itemHas($item, 'getFeedCommentRoute')) { if ($comments = $this->getComments($item)) { $xml->addTextNode('comments', $comments, $nodeItem); } } if ($this->itemHas($item, 'getFeedEnclosure')) { if ($enclosure = $this->getEnclosure($item, $xml)) { $nodeItem->appendChild($enclosure); } } }