diff --git a/README.md b/README.md index 1c40561..cabfb7f 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ $channel ->title('Channel Title') ->description('Channel Description') ->url('http://blog.example.com') + ->feedUrl('http://blog.example.com/rss') ->language('en-US') ->copyright('Copyright 2012, Foo Bar') ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900')) diff --git a/examples/simple-feed.php b/examples/simple-feed.php index 6443507..a96d33d 100644 --- a/examples/simple-feed.php +++ b/examples/simple-feed.php @@ -17,6 +17,7 @@ ->title('Channel Title') ->description('Channel Description') ->url('http://blog.example.com') + ->feedUrl('http://blog.example.com/rss') ->language('en-US') ->copyright('Copyright 2012, Foo Bar') ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900')) diff --git a/src/Suin/RSSWriter/Channel.php b/src/Suin/RSSWriter/Channel.php index 66b2b7d..72adae7 100644 --- a/src/Suin/RSSWriter/Channel.php +++ b/src/Suin/RSSWriter/Channel.php @@ -14,6 +14,9 @@ class Channel implements ChannelInterface /** @var string */ protected $url; + /** @var feedUrl */ + protected $feedUrl; + /** @var string */ protected $description; @@ -60,6 +63,17 @@ public function url($url) return $this; } + /** + * Set URL of this feed + * @param string $url + * @return $this; + */ + public function feedUrl($url) + { + $this->feedUrl = $url; + return $this; + } + /** * Set channel description * @param string $description @@ -180,6 +194,13 @@ public function asXML() $xml->addChild('link', $this->url); $xml->addChild('description', $this->description); + if($this->feedUrl !== null) { + $link = $xml->addChild('atom:link', '', "http://www.w3.org/2005/Atom"); + $link->addAttribute('href',$this->feedUrl); + $link->addAttribute('type','application/rss+xml'); + $link->addAttribute('rel','self'); + } + if ($this->language !== null) { $xml->addChild('language', $this->language); }