/**
* {@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);
}
}