public function makeItems(\SimpleXMLElement $xmlFeed) { $result = []; foreach ($xmlFeed->entry as $entry) { $feedItem = FeedItem::create((string) $entry->title); if (isset($entry->content)) { $feedItem->setContent($this->makeFeedItemContent($entry->content)); } if (isset($entry->summary)) { $feedItem->setSummary($this->makeFeedItemContent($entry->summary)); } if (isset($entry->id)) { $feedItem->setId($entry->id); } $result[] = $feedItem->setPublished(Timestamp::create(strtotime((string) $entry->updated)))->setLink((string) $entry->link); } return $result; }
public function toXml(FeedItem $item) { return '<item>' . ($item->getPublished() ? '<pubDate>' . date('r', $item->getPublished()->toStamp()) . '</pubDate>' : null) . ($item->getId() ? '<guid isPermaLink="false">' . $item->getId() . '</guid>' : null) . '<title>' . $item->getTitle() . '</title>' . ($item->getLink() ? '<link>' . str_replace("&", "&", $item->getLink()) . '</link>' : null) . ($item->getSummary() ? '<description>' . $item->getSummary() . '</description>' : null) . ($item->getFullText() ? '<yandex:full-text>' . $item->getFullText() . '</yandex:full-text>' : null) . ($item->getCategory() ? '<category>' . $item->getCategory() . '</category>' : null) . '</item>'; }