File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff 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'))
Original file line number Diff line number Diff line change 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 ' ))
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments