Skip to content

Commit

Permalink
Merge pull request #21 from christianp/atom_link
Browse files Browse the repository at this point in the history
add feed_url property
  • Loading branch information
suin authored Jul 13, 2017
2 parents 08cc21b + 123bce6 commit 78f45e4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
1 change: 1 addition & 0 deletions examples/simple-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
21 changes: 21 additions & 0 deletions src/Suin/RSSWriter/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class Channel implements ChannelInterface
/** @var string */
protected $url;

/** @var feedUrl */
protected $feedUrl;

/** @var string */
protected $description;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 78f45e4

Please sign in to comment.