Пример #1
0
 public function toXml(FeedChannel $channel)
 {
     $this->checkWorkers();
     $itemsXml = null;
     $itemWorker = $this->getItemWorker();
     foreach ($channel->getFeedItems() as $feedItem) {
         $itemsXml .= $itemWorker->toXml($feedItem);
     }
     return $this->getChannelWorker()->toXml($channel, $itemsXml);
 }
Пример #2
0
 /**
  * @return FeedChannel
  **/
 public function makeChannel(\SimpleXMLElement $xmlFeed)
 {
     $feedChannel = FeedChannel::create((string) $xmlFeed->title);
     if (isset($xmlFeed->link)) {
         if (is_array($xmlFeed->link)) {
             $feedChannel->setLink((string) $xmlFeed->link[0]);
         } else {
             $feedChannel->setLink((string) $xmlFeed->link);
         }
     }
     return $feedChannel;
 }
Пример #3
0
 public function toXml(FeedChannel $channel, $itemsXml)
 {
     return '<rss version="' . RssFeedFormat::VERSION . '">' . '<channel>' . '<title>' . $channel->getTitle() . '</title>' . ($channel->getLink() ? '<link>' . $channel->getLink() . '</link>' : null) . ($channel->getDescription() ? '<description>' . $channel->getDescription() . '</description>' : null) . $itemsXml . '</channel>' . '</rss>';
 }