/** * * @param XMLManager $xml * @param array $route * @throws \InvalidArgumentException * * @return \DOMNode */ private function createLink(XMLManager $xml, array $route) { $routeNode = $xml->getXml()->createElement('link'); $url = ''; if (!empty($route['route']) && is_array($route['route'])) { $url = $this->router->generate($route['route'][0], $route['route'][1]); } else { if (!empty($route['url'])) { $url = $route['url']; } else { throw new \InvalidArgumentException('The method getFeedRoutes must be an array of links. Check the ItemInterface.php for more details.'); } } $routeNode->setAttribute('href', $url); foreach ($route as $attribute => $value) { if ($attribute != 'route' && $attribute != 'url') { $routeNode->setAttribute($attribute, $value); } } return $routeNode; }
/** * Extract enclosure * * @param \Nekland\FeedBundle\Item\ExtendedItemInterface $item * @param \Nekland\FeedBundle\XML\XMLManager $xml * @return \DOMElement|null */ private function getEnclosure(ExtendedItemInterface $item, XMLManager $xml) { $enc = $item->getFeedEnclosure(); if (is_array($enc)) { $enclosure = $xml->getXml()->createElement('enclosure'); foreach ($enc as $key => $value) { $enclosure->setAttribute($key, $value); } return $enclosure; } return null; }