Ejemplo n.º 1
0
 /**
  * Set a feed param
  *
  * @param \SimpleXMLElement        $element
  * @param \Nekland\Bundle\FeedBundle\Feed $feed
  * @return void
  */
 protected function setParam(\SimpleXMLElement $element, Feed $feed)
 {
     if (count($element) === 0) {
         $feed->set($element->getName(), (string) $element);
     } else {
         $feed->set($element->getName(), $this->extractParam($element));
     }
 }
Ejemplo n.º 2
0
 /**
  * @Then /^the parameter "([^"]*)" is "([^"]*)"$/
  */
 public function theParameterIs($argument1, $argument2)
 {
     $this->assertEquals($this->feed->get($argument1), $argument2);
 }
Ejemplo n.º 3
0
 /**
  * Build the feed properties
  *
  * @param \Nekland\Bundle\FeedBundle\XML\XMLManager $xml
  * @param \Nekland\Bundle\FeedBundle\Feed           $feed
  * @return void
  */
 private function init(XMLManager $xml, Feed $feed)
 {
     $root = $xml->getXml()->createElement('rss');
     $root->setAttribute('version', '2.0');
     $root = $xml->getXml()->appendChild($root);
     $channel = $xml->getXml()->createElement('channel');
     $channel = $root->appendChild($channel);
     $xml->addTextNode('description', $feed->get('description'), $channel);
     $xml->addTextNode('pubDate', $feed->get('pubDate', new \DateTime())->format(\DateTime::RSS), $channel);
     $date = new \DateTime();
     $xml->addTextNode('lastBuildDate', $date->format(\DateTime::RSS), $channel);
     $xml->addTextNode('link', $feed->get('url'), $channel);
     $xml->addTextNode('title', $feed->get('title'), $channel);
     $xml->addTextNode('language', $feed->get('language'), $channel);
     if (null !== $feed->get('copyright')) {
         $xml->addTextNode('copyright', $feed->get('copyright'), $channel);
     }
     if (null !== $feed->get('managingEditor')) {
         $xml->addTextNode('managingEditor', $feed->get('managingEditor'), $channel);
     }
     if (null !== $feed->get('generator')) {
         $xml->addTextNode('generator', $feed->get('generator'), $channel);
     }
     if (null !== $feed->get('webMaster')) {
         $xml->addTextNode('webMaster', $feed->get('webMaster'), $channel);
     }
     $image = $feed->get('image', array());
     if (isset($image['url']) && isset($image['title']) && isset($image['link'])) {
         $imageNode = $xml->getXml()->createElement('image');
         $imageNode = $channel->appendChild($imageNode);
         $xml->addTextNode('url', $image['url'], $imageNode);
         $xml->addTextNode('title', $image['url'], $imageNode);
         $xml->addTextNode('link', $image['url'], $imageNode);
         if (isset($image['height'])) {
             $xml->addTextNode('height', $image['height'], $imageNode);
         }
         if (isset($image['width'])) {
             $xml->addTextNode('width', $image['width'], $imageNode);
         }
     }
     if (null !== $feed->get('ttl')) {
         $xml->addTextNode('ttl', $feed->get('ttl'), $channel);
     }
 }
Ejemplo n.º 4
0
 private function init(XMLManager $xml, Feed $feed)
 {
     $root = $xml->getXml()->createElement('feed');
     $root->setAttribute('xmlns', 'http://www.w3.org/2005/Atom');
     $root = $xml->getXml()->appendChild($root);
     $xml->addTextNode('title', $feed->get('title'), $root);
     if ($subtitle = $feed->get('subtitle')) {
         $xml->addTextNode('subtitle', $subtitle, $root);
     }
     $date = new \DateTime();
     $xml->addTextNode('updated', $date->format(\DateTime::ATOM), $root);
     if ($id = $feed->get('id')) {
         $xml->addTextNode('id', $id, $root);
     }
     if (null !== $feed->get('icon')) {
         $xml->addTextNode('icon', $feed->get('icon'), $root);
     }
     if (null !== $feed->get('image')) {
         $image = $feed->get('image');
         $xml->addTextNode('logo', $image['url'], $root);
     }
     if (null !== $feed->get('rights')) {
         $xml->addTextNode('rights', $feed->get('rights'), $root);
     }
     if (null !== $feed->get('url')) {
         $link = $xml->getXml()->createElement('link');
         $link->setAttribute('href', $feed->get('url'));
         $link = $root->appendChild($link);
     }
 }