public function Rss::getAuthors in Zircon Profile 8
Same name in this branch
- 8 vendor/zendframework/zend-feed/src/Reader/Entry/Rss.php \Zend\Feed\Reader\Entry\Rss::getAuthors()
- 8 vendor/zendframework/zend-feed/src/Reader/Feed/Rss.php \Zend\Feed\Reader\Feed\Rss::getAuthors()
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-feed/src/Reader/Feed/Rss.php \Zend\Feed\Reader\Feed\Rss::getAuthors()
Get an array with feed authors
Return value
array
Overrides FeedInterface::getAuthors
1 call to Rss::getAuthors()
- Rss::getAuthor in vendor/
zendframework/ zend-feed/ src/ Reader/ Feed/ Rss.php - Get a single author
File
- vendor/
zendframework/ zend-feed/ src/ Reader/ Feed/ Rss.php, line 80
Class
Namespace
Zend\Feed\Reader\FeedCode
public function getAuthors() {
if (array_key_exists('authors', $this->data)) {
return $this->data['authors'];
}
$authors = [];
$authorsDc = $this
->getExtension('DublinCore')
->getAuthors();
if (!empty($authorsDc)) {
foreach ($authorsDc as $author) {
$authors[] = [
'name' => $author['name'],
];
}
}
/**
* Technically RSS doesn't specific author element use at the feed level
* but it's supported on a "just in case" basis.
*/
if ($this
->getType() !== Reader\Reader::TYPE_RSS_10 && $this
->getType() !== Reader\Reader::TYPE_RSS_090) {
$list = $this->xpath
->query('//author');
}
else {
$list = $this->xpath
->query('//rss:author');
}
if ($list->length) {
foreach ($list as $author) {
$string = trim($author->nodeValue);
$data = [];
// Pretty rough parsing - but it's a catchall
if (preg_match("/^.*@[^ ]*/", $string, $matches)) {
$data['email'] = trim($matches[0]);
if (preg_match("/\\((.*)\\)\$/", $string, $matches)) {
$data['name'] = $matches[1];
}
$authors[] = $data;
}
}
}
if (count($authors) == 0) {
$authors = $this
->getExtension('Atom')
->getAuthors();
}
else {
$authors = new Reader\Collection\Author(Reader\Reader::arrayUnique($authors));
}
if (count($authors) == 0) {
$authors = null;
}
$this->data['authors'] = $authors;
return $this->data['authors'];
}