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
22
22
->title('Channel Title')
23
23
->description('Channel Description')
24
24
->url('http://blog.example.com')
25
+ ->feedUrl('http://blog.example.com/rss')
25
26
->language('en-US')
26
27
->copyright('Copyright 2012, Foo Bar')
27
28
->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
Original file line number Diff line number Diff line change 17
17
->title ('Channel Title ' )
18
18
->description ('Channel Description ' )
19
19
->url ('http://blog.example.com ' )
20
+ ->feedUrl ('http://blog.example.com/rss ' )
20
21
->language ('en-US ' )
21
22
->copyright ('Copyright 2012, Foo Bar ' )
22
23
->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
14
14
/** @var string */
15
15
protected $ url ;
16
16
17
+ /** @var feedUrl */
18
+ protected $ feedUrl ;
19
+
17
20
/** @var string */
18
21
protected $ description ;
19
22
@@ -60,6 +63,17 @@ public function url($url)
60
63
return $ this ;
61
64
}
62
65
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
+
63
77
/**
64
78
* Set channel description
65
79
* @param string $description
@@ -180,6 +194,13 @@ public function asXML()
180
194
$ xml ->addChild ('link ' , $ this ->url );
181
195
$ xml ->addChild ('description ' , $ this ->description );
182
196
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
+
183
204
if ($ this ->language !== null ) {
184
205
$ xml ->addChild ('language ' , $ this ->language );
185
206
}
You can’t perform that action at this time.
0 commit comments