Skip to content

Commit 08cc21b

Browse files
authored
Merge pull request #20 from christianp/item_creator
add creator field to Item
2 parents de25f01 + 4a815a1 commit 08cc21b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

examples/simple-feed.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
->description('<div>Blog body</div>')
3333
->contentEncoded('<div>Blog body</div>')
3434
->url('http://blog.example.com/2012/08/21/blog-entry/')
35-
->author('John Smith')
35+
->author('[email protected]')
36+
->creator('John Smith')
3637
->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
3738
->guid('http://blog.example.com/2012/08/21/blog-entry/', true)
3839
->preferCdata(true) // By this, title and description become CDATA wrapped HTML.

src/Suin/RSSWriter/Item.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class Item implements ItemInterface
3838
/** @var string */
3939
protected $author;
4040

41+
/** @var string */
42+
protected $creator;
43+
4144
protected $preferCdata = false;
4245

4346
public function title($title)
@@ -95,6 +98,12 @@ public function author($author)
9598
return $this;
9699
}
97100

101+
public function creator($creator)
102+
{
103+
$this->creator = $creator;
104+
return $this;
105+
}
106+
98107
public function preferCdata($preferCdata)
99108
{
100109
$this->preferCdata = (bool)$preferCdata;
@@ -163,6 +172,10 @@ public function asXML()
163172
$xml->addChild('author', $this->author);
164173
}
165174

175+
if (!empty($this->creator)) {
176+
$xml->addChild('dc:creator', $this->creator,"http://purl.org/dc/elements/1.1/");
177+
}
178+
166179
return $xml;
167180
}
168181
}

0 commit comments

Comments
 (0)