Skip to content

Commit 78f45e4

Browse files
authored
Merge pull request #21 from christianp/atom_link
add feed_url property
2 parents 08cc21b + 123bce6 commit 78f45e4

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ $channel
2222
->title('Channel Title')
2323
->description('Channel Description')
2424
->url('http://blog.example.com')
25+
->feedUrl('http://blog.example.com/rss')
2526
->language('en-US')
2627
->copyright('Copyright 2012, Foo Bar')
2728
->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))

examples/simple-feed.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
->title('Channel Title')
1818
->description('Channel Description')
1919
->url('http://blog.example.com')
20+
->feedUrl('http://blog.example.com/rss')
2021
->language('en-US')
2122
->copyright('Copyright 2012, Foo Bar')
2223
->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))

src/Suin/RSSWriter/Channel.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class Channel implements ChannelInterface
1414
/** @var string */
1515
protected $url;
1616

17+
/** @var feedUrl */
18+
protected $feedUrl;
19+
1720
/** @var string */
1821
protected $description;
1922

@@ -60,6 +63,17 @@ public function url($url)
6063
return $this;
6164
}
6265

66+
/**
67+
* Set URL of this feed
68+
* @param string $url
69+
* @return $this;
70+
*/
71+
public function feedUrl($url)
72+
{
73+
$this->feedUrl = $url;
74+
return $this;
75+
}
76+
6377
/**
6478
* Set channel description
6579
* @param string $description
@@ -180,6 +194,13 @@ public function asXML()
180194
$xml->addChild('link', $this->url);
181195
$xml->addChild('description', $this->description);
182196

197+
if($this->feedUrl !== null) {
198+
$link = $xml->addChild('atom:link', '', "http://www.w3.org/2005/Atom");
199+
$link->addAttribute('href',$this->feedUrl);
200+
$link->addAttribute('type','application/rss+xml');
201+
$link->addAttribute('rel','self');
202+
}
203+
183204
if ($this->language !== null) {
184205
$xml->addChild('language', $this->language);
185206
}

0 commit comments

Comments
 (0)