/** * {@inheritdoc} */ public function initialize() { parent::initialize(); $encoding = $this->feed->get('encoding'); $this->dom = new \DOMDocument('1.0', $encoding); $root = $this->dom->createElement('rss'); $root->setAttribute('version', '2.0'); $root = $this->dom->appendChild($root); $channel = $this->dom->createElement('channel'); $channel = $root->appendChild($channel); $title = $this->translate($this->feed->get('title')); $title = $this->dom->createElement('title', $title); $channel->appendChild($title); $description = $this->translate($this->feed->get('description')); $description = $this->dom->createElement('description', $description); $channel->appendChild($description); $link = $this->dom->createElement('link', $this->feed->get('link')); $channel->appendChild($link); $date = new \DateTime(); $lastBuildDate = $this->dom->createElement('lastBuildDate', $date->format(\DateTime::RSS)); $channel->appendChild($lastBuildDate); // Add custom channel fields $this->addChannelFields($channel); // Add feed items $items = $this->feed->getItems(); foreach ($items as $item) { $this->addItem($channel, $item); } }
/** * {@inheritdoc} */ public function initialize() { parent::initialize(); $encoding = $this->feed->get('encoding'); $this->dom = new \DOMDocument('1.0', $encoding); $channel = $this->dom->createElement('feed'); $channel->setAttribute('xmlns', 'http://www.w3.org/2005/Atom'); $channel = $this->dom->appendChild($channel); $identifier = $this->dom->createElement('id', $this->feed->get('link')); $title = $this->translate($this->feed->get('title')); $title = $this->dom->createElement('title', $title); $description = $this->translate($this->feed->get('description')); $subtitle = $this->dom->createElement('subtitle', $description); $name = $this->dom->createElement('name', $this->feed->get('author')); $link = $this->dom->createElement('link'); $link->setAttribute('href', $this->feed->get('link')); $link->setAttribute('rel', 'self'); $link->setAttribute('type', 'application/rss+xml'); $date = new \DateTime(); $updated = $this->dom->createElement('updated', $date->format(\DateTime::ATOM)); $author = $this->dom->createElement('author'); $author->appendChild($name); $channel->appendChild($title); $channel->appendChild($subtitle); $channel->appendChild($link); $channel->appendChild($updated); $channel->appendChild($identifier); $channel->appendChild($author); // Add custom channel fields $this->addChannelFields($channel); // Add field items $items = $this->feed->getItems(); foreach ($items as $item) { if (null === $item) { continue; } $this->addItem($channel, $item); } }