Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2694' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 9 deletions.
69 changes: 65 additions & 4 deletions src/Writer/AbstractFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct()
*
* @param array $author
* @throws Exception\InvalidArgumentException If any value of $author not follow the format.
* @return void
* @return AbstractFeed
*/
public function addAuthor(array $author)
{
Expand Down Expand Up @@ -90,41 +90,49 @@ public function addAuthor(array $author)
}

$this->data['authors'][] = $author;

return $this;
}

/**
* Set an array with feed authors
*
* @see addAuthor
* @param array $authors
* @return void
* @return AbstractFeed
*/
public function addAuthors(array $authors)
{
foreach ($authors as $author) {
$this->addAuthor($author);
}

return $this;
}

/**
* Set the copyright entry
*
* @param string $copyright
* @param string $copyright
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setCopyright($copyright)
{
if (empty($copyright) || !is_string($copyright)) {
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
}
$this->data['copyright'] = $copyright;

return $this;
}

/**
* Set the feed creation date
*
* @param null|integer|DateTime
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setDateCreated($date = null)
{
Expand All @@ -137,13 +145,16 @@ public function setDateCreated($date = null)
. ' passed as parameter');
}
$this->data['dateCreated'] = $date;

return $this;
}

/**
* Set the feed modification date
*
* @param null|integer|DateTime
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setDateModified($date = null)
{
Expand All @@ -156,13 +167,16 @@ public function setDateModified($date = null)
. ' passed as parameter');
}
$this->data['dateModified'] = $date;

return $this;
}

/**
* Set the feed last-build date. Ignored for Atom 1.0.
*
* @param null|integer|DateTime
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setLastBuildDate($date = null)
{
Expand All @@ -175,20 +189,25 @@ public function setLastBuildDate($date = null)
. ' passed as parameter');
}
$this->data['lastBuildDate'] = $date;

return $this;
}

/**
* Set the feed description
*
* @param string $description
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setDescription($description)
{
if (empty($description) || !is_string($description)) {
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
}
$this->data['description'] = $description;

return $this;
}

/**
Expand All @@ -198,7 +217,7 @@ public function setDescription($description)
* @param null|string $version
* @param null|string $uri
* @throws Exception\InvalidArgumentException
* @return string|null
* @return AbstractFeed
*/
public function setGenerator($name, $version = null, $uri = null)
{
Expand Down Expand Up @@ -239,13 +258,16 @@ public function setGenerator($name, $version = null, $uri = null)
}
}
$this->data['generator'] = $generator;

return $this;
}

/**
* Set the feed ID - URI or URN (via PCRE pattern) supported
*
* @param string $id
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setId($id)
{
Expand All @@ -256,6 +278,8 @@ public function setId($id)
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
}
$this->data['id'] = $id;

return $this;
}

/**
Expand Down Expand Up @@ -298,6 +322,7 @@ protected function _validateTagUri($id)
*
* @param array $data
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setImage(array $data)
{
Expand All @@ -308,34 +333,42 @@ public function setImage(array $data)
. ' must be a non-empty string and valid URI/IRI');
}
$this->data['image'] = $data;

return $this;
}

/**
* Set the feed language
*
* @param string $language
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setLanguage($language)
{
if (empty($language) || !is_string($language)) {
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
}
$this->data['language'] = $language;

return $this;
}

/**
* Set a link to the HTML source
*
* @param string $link
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setLink($link)
{
if (empty($link) || !is_string($link) || !Uri\UriFactory::factory($link)->isValid()) {
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
}
$this->data['link'] = $link;

return $this;
}

/**
Expand All @@ -344,6 +377,7 @@ public function setLink($link)
* @param string $link
* @param string $type
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setFeedLink($link, $type)
{
Expand All @@ -354,41 +388,50 @@ public function setFeedLink($link, $type)
throw new Exception\InvalidArgumentException('Invalid parameter: "type"; You must declare the type of feed the link points to, i.e. RSS, RDF or Atom');
}
$this->data['feedLinks'][strtolower($type)] = $link;

return $this;
}

/**
* Set the feed title
*
* @param string $title
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setTitle($title)
{
if (empty($title) || !is_string($title)) {
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
}
$this->data['title'] = $title;

return $this;
}

/**
* Set the feed character encoding
*
* @param string $encoding
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setEncoding($encoding)
{
if (empty($encoding) || !is_string($encoding)) {
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
}
$this->data['encoding'] = $encoding;

return $this;
}

/**
* Set the feed's base URL
*
* @param string $url
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function setBaseUrl($url)
{
Expand All @@ -397,13 +440,16 @@ public function setBaseUrl($url)
. ' must be a non-empty string and valid URI/IRI');
}
$this->data['baseUrl'] = $url;

return $this;
}

/**
* Add a Pubsubhubbub hub endpoint URL
*
* @param string $url
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function addHub($url)
{
Expand All @@ -415,25 +461,31 @@ public function addHub($url)
$this->data['hubs'] = array();
}
$this->data['hubs'][] = $url;

return $this;
}

/**
* Add Pubsubhubbub hub endpoint URLs
*
* @param array $urls
* @return AbstractFeed
*/
public function addHubs(array $urls)
{
foreach ($urls as $url) {
$this->addHub($url);
}

return $this;
}

/**
* Add a feed category
*
* @param array $category
* @throws Exception\InvalidArgumentException
* @return AbstractFeed
*/
public function addCategory(array $category)
{
Expand All @@ -455,18 +507,23 @@ public function addCategory(array $category)
$this->data['categories'] = array();
}
$this->data['categories'][] = $category;

return $this;
}

/**
* Set an array of feed categories
*
* @param array $categories
* @return AbstractFeed
*/
public function addCategories(array $categories)
{
foreach ($categories as $category) {
$this->addCategory($category);
}

return $this;
}

/**
Expand Down Expand Up @@ -721,10 +778,12 @@ public function reset()
* on their appropriateness for the current type, e.g. renderers.
*
* @param string $type
* @return AbstractFeed
*/
public function setType($type)
{
$this->type = $type;
return $this;
}

/**
Expand All @@ -741,12 +800,14 @@ public function getType()
* Unset a specific data point
*
* @param string $name
* @return AbstractFeed
*/
public function remove($name)
{
if (isset($this->data[$name])) {
unset($this->data[$name]);
}
return $this;
}

/**
Expand Down
Loading

0 comments on commit 4179b4d

Please sign in to comment.