Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -67,7 +67,7 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
throw new Exception\InvalidArgumentException('Array or Traversable object'
|
||||
. 'expected, got ' . gettype($options));
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
*/
|
||||
public function setHttpResponse($httpResponse)
|
||||
{
|
||||
if (!$httpResponse instanceof HttpResponse && !$httpResponse instanceof PhpResponse) {
|
||||
if (! $httpResponse instanceof HttpResponse && ! $httpResponse instanceof PhpResponse) {
|
||||
throw new Exception\InvalidArgumentException('HTTP Response object must'
|
||||
. ' implement one of Zend\Feed\Pubsubhubbub\HttpResponse or'
|
||||
. ' Zend\Http\PhpEnvironment\Response');
|
||||
|
@ -196,8 +196,10 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
* Attempt to detect the callback URL (specifically the path forward)
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _detectCallbackUrl()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$callbackUrl = '';
|
||||
if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
|
||||
$callbackUrl = $_SERVER['HTTP_X_ORIGINAL_URL'];
|
||||
|
@ -214,8 +216,8 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
$callbackUrl = substr($callbackUrl, strlen($schemeAndHttpHost));
|
||||
}
|
||||
} elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
|
||||
$callbackUrl= $_SERVER['ORIG_PATH_INFO'];
|
||||
if (!empty($_SERVER['QUERY_STRING'])) {
|
||||
$callbackUrl = $_SERVER['ORIG_PATH_INFO'];
|
||||
if (! empty($_SERVER['QUERY_STRING'])) {
|
||||
$callbackUrl .= '?' . $_SERVER['QUERY_STRING'];
|
||||
}
|
||||
}
|
||||
|
@ -227,9 +229,11 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getHttpHost()
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_HOST'])) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! empty($_SERVER['HTTP_HOST'])) {
|
||||
return $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
$scheme = 'http';
|
||||
|
@ -253,19 +257,21 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
* @param string $header
|
||||
* @return bool|string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getHeader($header)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$temp = strtoupper(str_replace('-', '_', $header));
|
||||
if (!empty($_SERVER[$temp])) {
|
||||
if (! empty($_SERVER[$temp])) {
|
||||
return $_SERVER[$temp];
|
||||
}
|
||||
$temp = 'HTTP_' . strtoupper(str_replace('-', '_', $header));
|
||||
if (!empty($_SERVER[$temp])) {
|
||||
if (! empty($_SERVER[$temp])) {
|
||||
return $_SERVER[$temp];
|
||||
}
|
||||
if (function_exists('apache_request_headers')) {
|
||||
$headers = apache_request_headers();
|
||||
if (!empty($headers[$header])) {
|
||||
if (! empty($headers[$header])) {
|
||||
return $headers[$header];
|
||||
}
|
||||
}
|
||||
|
@ -277,8 +283,10 @@ abstract class AbstractCallback implements CallbackInterface
|
|||
*
|
||||
* @return string|false Raw body, or false if not present
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getRawBody()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$body = file_get_contents('php://input');
|
||||
if (strlen(trim($body)) == 0 && isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
|
||||
$body = $GLOBALS['HTTP_RAW_POST_DATA'];
|
||||
|
|
|
@ -60,14 +60,14 @@ class HttpResponse
|
|||
}
|
||||
$httpCodeSent = false;
|
||||
foreach ($this->headers as $header) {
|
||||
if (!$httpCodeSent && $this->statusCode) {
|
||||
if (! $httpCodeSent && $this->statusCode) {
|
||||
header($header['name'] . ': ' . $header['value'], $header['replace'], $this->statusCode);
|
||||
$httpCodeSent = true;
|
||||
} else {
|
||||
header($header['name'] . ': ' . $header['value'], $header['replace']);
|
||||
}
|
||||
}
|
||||
if (!$httpCodeSent) {
|
||||
if (! $httpCodeSent) {
|
||||
header('HTTP/1.1 ' . $this->statusCode);
|
||||
}
|
||||
}
|
||||
|
@ -140,9 +140,11 @@ class HttpResponse
|
|||
{
|
||||
$ok = headers_sent($file, $line);
|
||||
if ($ok && $throw) {
|
||||
throw new Exception\RuntimeException('Cannot send headers; headers already sent in ' . $file . ', line ' . $line);
|
||||
throw new Exception\RuntimeException(
|
||||
'Cannot send headers; headers already sent in ' . $file . ', line ' . $line
|
||||
);
|
||||
}
|
||||
return !$ok;
|
||||
return ! $ok;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,7 +156,7 @@ class HttpResponse
|
|||
*/
|
||||
public function setStatusCode($code)
|
||||
{
|
||||
if (!is_int($code) || (100 > $code) || (599 < $code)) {
|
||||
if (! is_int($code) || (100 > $code) || (599 < $code)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid HTTP response'
|
||||
. ' code:' . $code);
|
||||
}
|
||||
|
@ -201,8 +203,10 @@ class HttpResponse
|
|||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _normalizeHeader($name)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$filtered = str_replace(['-', '_'], ' ', (string) $name);
|
||||
$filtered = ucwords(strtolower($filtered));
|
||||
$filtered = str_replace(' ', '-', $filtered);
|
||||
|
|
|
@ -31,7 +31,7 @@ class Subscription extends AbstractModel implements SubscriptionPersistenceInter
|
|||
*/
|
||||
public function setSubscription(array $data)
|
||||
{
|
||||
if (!isset($data['id'])) {
|
||||
if (! isset($data['id'])) {
|
||||
throw new PubSubHubbub\Exception\InvalidArgumentException(
|
||||
'ID must be set before attempting a save'
|
||||
);
|
||||
|
@ -66,7 +66,7 @@ class Subscription extends AbstractModel implements SubscriptionPersistenceInter
|
|||
*/
|
||||
public function getSubscription($key)
|
||||
{
|
||||
if (empty($key) || !is_string($key)) {
|
||||
if (empty($key) || ! is_string($key)) {
|
||||
throw new PubSubHubbub\Exception\InvalidArgumentException('Invalid parameter "key"'
|
||||
.' of "' . $key . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class Subscription extends AbstractModel implements SubscriptionPersistenceInter
|
|||
*/
|
||||
public function hasSubscription($key)
|
||||
{
|
||||
if (empty($key) || !is_string($key)) {
|
||||
if (empty($key) || ! is_string($key)) {
|
||||
throw new PubSubHubbub\Exception\InvalidArgumentException('Invalid parameter "key"'
|
||||
.' of "' . $key . '" must be a non-empty string');
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ class PubSubHubbub
|
|||
*/
|
||||
public static function getHttpClient()
|
||||
{
|
||||
if (!isset(static::$httpClient)) {
|
||||
if (! isset(static::$httpClient)) {
|
||||
static::$httpClient = new Http\Client;
|
||||
} else {
|
||||
static::$httpClient->resetParameters();
|
||||
|
|
|
@ -75,7 +75,7 @@ class Publisher
|
|||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
throw new Exception\InvalidArgumentException('Array or Traversable object'
|
||||
. 'expected, got ' . gettype($options));
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class Publisher
|
|||
*/
|
||||
public function addHubUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. 'URL');
|
||||
|
@ -131,7 +131,7 @@ class Publisher
|
|||
*/
|
||||
public function removeHubUrl($url)
|
||||
{
|
||||
if (!in_array($url, $this->getHubUrls())) {
|
||||
if (! in_array($url, $this->getHubUrls())) {
|
||||
return $this;
|
||||
}
|
||||
$key = array_search($url, $this->hubUrls);
|
||||
|
@ -159,7 +159,7 @@ class Publisher
|
|||
*/
|
||||
public function addUpdatedTopicUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. 'URL');
|
||||
|
@ -190,7 +190,7 @@ class Publisher
|
|||
*/
|
||||
public function removeUpdatedTopicUrl($url)
|
||||
{
|
||||
if (!in_array($url, $this->getUpdatedTopicUrls())) {
|
||||
if (! in_array($url, $this->getUpdatedTopicUrls())) {
|
||||
return $this;
|
||||
}
|
||||
$key = array_search($url, $this->updatedTopicUrls);
|
||||
|
@ -219,7 +219,7 @@ class Publisher
|
|||
*/
|
||||
public function notifyHub($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. 'URL');
|
||||
|
@ -281,7 +281,7 @@ class Publisher
|
|||
$this->setParameters($name);
|
||||
return $this;
|
||||
}
|
||||
if (empty($name) || !is_string($name)) {
|
||||
if (empty($name) || ! is_string($name)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "name"'
|
||||
. ' of "' . $name . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ class Publisher
|
|||
$this->removeParameter($name);
|
||||
return $this;
|
||||
}
|
||||
if (empty($value) || (!is_string($value) && $value !== null)) {
|
||||
if (empty($value) || (! is_string($value) && $value !== null)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "value"'
|
||||
. ' of "' . $value . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ class Publisher
|
|||
*/
|
||||
public function removeParameter($name)
|
||||
{
|
||||
if (empty($name) || !is_string($name)) {
|
||||
if (empty($name) || ! is_string($name)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "name"'
|
||||
. ' of "' . $name . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ class Publisher
|
|||
*/
|
||||
public function isSuccess()
|
||||
{
|
||||
return !(count($this->errors) != 0);
|
||||
return ! (count($this->errors) != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -369,8 +369,10 @@ class Publisher
|
|||
* @return \Zend\Http\Client
|
||||
* @throws Exception\RuntimeException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getHttpClient()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$client = PubSubHubbub::getHttpClient();
|
||||
$client->setMethod(HttpRequest::METHOD_POST);
|
||||
$client->setOptions([
|
||||
|
|
|
@ -147,7 +147,7 @@ class Subscriber
|
|||
$options = ArrayUtils::iteratorToArray($options);
|
||||
}
|
||||
|
||||
if (!is_array($options)) {
|
||||
if (! is_array($options)) {
|
||||
throw new Exception\InvalidArgumentException('Array or Traversable object'
|
||||
. 'expected, got ' . gettype($options));
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class Subscriber
|
|||
*/
|
||||
public function setTopicUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
.' of "' . $url . '" must be a non-empty string and a valid'
|
||||
.' URL');
|
||||
|
@ -256,7 +256,7 @@ class Subscriber
|
|||
*/
|
||||
public function setCallbackUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. ' URL');
|
||||
|
@ -326,7 +326,7 @@ class Subscriber
|
|||
*/
|
||||
public function addHubUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. ' URL');
|
||||
|
@ -357,7 +357,7 @@ class Subscriber
|
|||
*/
|
||||
public function removeHubUrl($url)
|
||||
{
|
||||
if (!in_array($url, $this->getHubUrls())) {
|
||||
if (! in_array($url, $this->getHubUrls())) {
|
||||
return $this;
|
||||
}
|
||||
$key = array_search($url, $this->hubUrls);
|
||||
|
@ -386,7 +386,7 @@ class Subscriber
|
|||
*/
|
||||
public function addAuthentication($url, array $authentication)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "url"'
|
||||
. ' of "' . $url . '" must be a non-empty string and a valid'
|
||||
. ' URL');
|
||||
|
@ -445,7 +445,7 @@ class Subscriber
|
|||
$this->setParameters($name);
|
||||
return $this;
|
||||
}
|
||||
if (empty($name) || !is_string($name)) {
|
||||
if (empty($name) || ! is_string($name)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "name"'
|
||||
. ' of "' . $name . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ class Subscriber
|
|||
$this->removeParameter($name);
|
||||
return $this;
|
||||
}
|
||||
if (empty($value) || (!is_string($value) && $value !== null)) {
|
||||
if (empty($value) || (! is_string($value) && $value !== null)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "value"'
|
||||
. ' of "' . $value . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -484,7 +484,7 @@ class Subscriber
|
|||
*/
|
||||
public function removeParameter($name)
|
||||
{
|
||||
if (empty($name) || !is_string($name)) {
|
||||
if (empty($name) || ! is_string($name)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter "name"'
|
||||
. ' of "' . $name . '" must be a non-empty string');
|
||||
}
|
||||
|
@ -602,8 +602,10 @@ class Subscriber
|
|||
* @return void
|
||||
* @throws Exception\RuntimeException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _doRequest($mode)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$client = $this->_getHttpClient();
|
||||
$hubs = $this->getHubUrls();
|
||||
if (empty($hubs)) {
|
||||
|
@ -648,8 +650,10 @@ class Subscriber
|
|||
*
|
||||
* @return \Zend\Http\Client
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getHttpClient()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$client = PubSubHubbub::getHttpClient();
|
||||
$client->setMethod(HttpRequest::METHOD_POST);
|
||||
$client->setOptions(['useragent' => 'Zend_Feed_Pubsubhubbub_Subscriber/'
|
||||
|
@ -666,9 +670,11 @@ class Subscriber
|
|||
* @return string
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _getRequestParameters($hubUrl, $mode)
|
||||
{
|
||||
if (!in_array($mode, ['subscribe', 'unsubscribe'])) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! in_array($mode, ['subscribe', 'unsubscribe'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid mode specified: "'
|
||||
. $mode . '" which should have been "subscribe" or "unsubscribe"');
|
||||
}
|
||||
|
@ -705,7 +711,7 @@ class Subscriber
|
|||
$params['hub.verify_token'] = $token;
|
||||
|
||||
// Note: query string only usable with PuSH 0.2 Hubs
|
||||
if (!$this->usePathParameter) {
|
||||
if (! $this->usePathParameter) {
|
||||
$params['hub.callback'] = $this->getCallbackUrl()
|
||||
. '?xhub.subscription=' . PubSubHubbub::urlencode($key);
|
||||
} else {
|
||||
|
@ -738,7 +744,9 @@ class Subscriber
|
|||
'verify_token' => hash('sha256', $params['hub.verify_token']),
|
||||
'secret' => null,
|
||||
'expiration_time' => $expires,
|
||||
'subscription_state' => ($mode == 'unsubscribe')? PubSubHubbub::SUBSCRIPTION_TODELETE : PubSubHubbub::SUBSCRIPTION_NOTVERIFIED,
|
||||
// @codingStandardsIgnoreStart
|
||||
'subscription_state' => ($mode == 'unsubscribe') ? PubSubHubbub::SUBSCRIPTION_TODELETE : PubSubHubbub::SUBSCRIPTION_NOTVERIFIED,
|
||||
// @codingStandardsIgnoreEnd
|
||||
];
|
||||
$this->getStorage()->setSubscription($data);
|
||||
|
||||
|
@ -754,9 +762,11 @@ class Subscriber
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _generateVerifyToken()
|
||||
{
|
||||
if (!empty($this->testStaticToken)) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! empty($this->testStaticToken)) {
|
||||
return $this->testStaticToken;
|
||||
}
|
||||
return uniqid(rand(), true) . time();
|
||||
|
@ -770,8 +780,10 @@ class Subscriber
|
|||
* @param string $hubUrl The Hub Server URL for which this token will apply
|
||||
* @return string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _generateSubscriptionKey(array $params, $hubUrl)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$keyBase = $params['hub.topic'] . $hubUrl;
|
||||
$key = md5($keyBase);
|
||||
|
||||
|
@ -784,8 +796,10 @@ class Subscriber
|
|||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _urlEncode(array $params)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$encoded = [];
|
||||
foreach ($params as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
|
@ -809,8 +823,10 @@ class Subscriber
|
|||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _toByteValueOrderedString(array $params)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$return = [];
|
||||
uksort($params, 'strnatcmp');
|
||||
foreach ($params as $key => $value) {
|
||||
|
|
|
@ -147,7 +147,7 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
'hub_verify_token',
|
||||
];
|
||||
foreach ($required as $key) {
|
||||
if (!array_key_exists($key, $httpGetData)) {
|
||||
if (! array_key_exists($key, $httpGetData)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -157,11 +157,11 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
return false;
|
||||
}
|
||||
if ($httpGetData['hub_mode'] == 'subscribe'
|
||||
&& !array_key_exists('hub_lease_seconds', $httpGetData)
|
||||
&& ! array_key_exists('hub_lease_seconds', $httpGetData)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
if (!Uri::factory($httpGetData['hub_topic'])->isValid()) {
|
||||
if (! Uri::factory($httpGetData['hub_topic'])->isValid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
* Attempt to retrieve any Verification Token Key attached to Callback
|
||||
* URL's path by our Subscriber implementation
|
||||
*/
|
||||
if (!$this->_hasValidVerifyToken($httpGetData)) {
|
||||
if (! $this->_hasValidVerifyToken($httpGetData)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -220,14 +220,16 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
* @param bool $checkValue
|
||||
* @return bool
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _hasValidVerifyToken(array $httpGetData = null, $checkValue = true)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$verifyTokenKey = $this->_detectVerifyTokenKey($httpGetData);
|
||||
if (empty($verifyTokenKey)) {
|
||||
return false;
|
||||
}
|
||||
$verifyTokenExists = $this->getStorage()->hasSubscription($verifyTokenKey);
|
||||
if (!$verifyTokenExists) {
|
||||
if (! $verifyTokenExists) {
|
||||
return false;
|
||||
}
|
||||
if ($checkValue) {
|
||||
|
@ -250,8 +252,10 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
* @param null|array $httpGetData
|
||||
* @return false|string
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _detectVerifyTokenKey(array $httpGetData = null)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
/**
|
||||
* Available when sub keys encoding in Callback URL path
|
||||
*/
|
||||
|
@ -286,8 +290,10 @@ class Callback extends PubSubHubbub\AbstractCallback
|
|||
*
|
||||
* @return array|void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _parseQueryString()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$params = [];
|
||||
$queryString = '';
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
|
|
|
@ -141,7 +141,7 @@ abstract class AbstractEntry
|
|||
*/
|
||||
public function getXpath()
|
||||
{
|
||||
if (!$this->xpath) {
|
||||
if (! $this->xpath) {
|
||||
$this->setXpath(new DOMXPath($this->getDomDocument()));
|
||||
}
|
||||
return $this->xpath;
|
||||
|
@ -207,8 +207,10 @@ abstract class AbstractEntry
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _loadExtensions()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$all = Reader::getExtensions();
|
||||
$feed = $all['entry'];
|
||||
foreach ($feed as $extension) {
|
||||
|
|
|
@ -23,7 +23,7 @@ class Category extends AbstractCollection
|
|||
{
|
||||
$categories = [];
|
||||
foreach ($this->getIterator() as $element) {
|
||||
if (isset($element['label']) && !empty($element['label'])) {
|
||||
if (isset($element['label']) && ! empty($element['label'])) {
|
||||
$categories[] = $element['label'];
|
||||
} else {
|
||||
$categories[] = $element['term'];
|
||||
|
|
|
@ -146,7 +146,7 @@ abstract class AbstractEntry
|
|||
*/
|
||||
public function getXpath()
|
||||
{
|
||||
if (!$this->xpath) {
|
||||
if (! $this->xpath) {
|
||||
$this->setXpath(new DOMXPath($this->getDomDocument()));
|
||||
}
|
||||
return $this->xpath;
|
||||
|
|
|
@ -104,7 +104,7 @@ class Atom extends AbstractEntry implements EntryInterface
|
|||
/**
|
||||
* Get the entry creation date
|
||||
*
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ class Atom extends AbstractEntry implements EntryInterface
|
|||
/**
|
||||
* Get the entry modification date
|
||||
*
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
|
@ -199,7 +199,7 @@ class Atom extends AbstractEntry implements EntryInterface
|
|||
*/
|
||||
public function getLink($index = 0)
|
||||
{
|
||||
if (!array_key_exists('links', $this->data)) {
|
||||
if (! array_key_exists('links', $this->data)) {
|
||||
$this->getLinks();
|
||||
}
|
||||
|
||||
|
@ -269,7 +269,7 @@ class Atom extends AbstractEntry implements EntryInterface
|
|||
|
||||
$commentcount = $this->getExtension('Thread')->getCommentCount();
|
||||
|
||||
if (!$commentcount) {
|
||||
if (! $commentcount) {
|
||||
$commentcount = $this->getExtension('Atom')->getCommentCount();
|
||||
}
|
||||
|
||||
|
|
|
@ -38,14 +38,14 @@ interface EntryInterface
|
|||
/**
|
||||
* Get the entry creation date
|
||||
*
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateCreated();
|
||||
|
||||
/**
|
||||
* Get the entry modification date
|
||||
*
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateModified();
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
public function __construct(DOMElement $entry, $entryKey, $type = null)
|
||||
{
|
||||
parent::__construct($entry, $entryKey, $type);
|
||||
$this->xpathQueryRss = '//item[' . ($this->entryKey+1) . ']';
|
||||
$this->xpathQueryRdf = '//rss:item[' . ($this->entryKey+1) . ']';
|
||||
$this->xpathQueryRss = '//item[' . ($this->entryKey + 1) . ']';
|
||||
$this->xpathQueryRdf = '//rss:item[' . ($this->entryKey + 1) . ']';
|
||||
|
||||
$manager = Reader\Reader::getExtensionManager();
|
||||
$extensions = [
|
||||
|
@ -92,7 +92,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
|
||||
$authors = [];
|
||||
$authorsDc = $this->getExtension('DublinCore')->getAuthors();
|
||||
if (!empty($authorsDc)) {
|
||||
if (! empty($authorsDc)) {
|
||||
foreach ($authorsDc as $author) {
|
||||
$authors[] = [
|
||||
'name' => $author['name']
|
||||
|
@ -151,7 +151,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
|
||||
$content = $this->getExtension('Content')->getContent();
|
||||
|
||||
if (!$content) {
|
||||
if (! $content) {
|
||||
$content = $this->getDescription();
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
/**
|
||||
* Get the entry's date of creation
|
||||
*
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
* Get the entry's date of modification
|
||||
*
|
||||
* @throws Exception\RuntimeException
|
||||
* @return string
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
|
@ -209,7 +209,8 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
'Could not load date due to unrecognised'
|
||||
.' format (should follow RFC 822 or 2822):'
|
||||
. $e->getMessage(),
|
||||
0, $e
|
||||
0,
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -218,15 +219,15 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
}
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getExtension('DublinCore')->getDate();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getExtension('Atom')->getDateModified();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = null;
|
||||
}
|
||||
|
||||
|
@ -256,7 +257,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$description = $this->xpath->evaluate('string(' . $this->xpathQueryRdf . '/rss:description)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = $this->getExtension('DublinCore')->getDescription();
|
||||
}
|
||||
|
||||
|
@ -264,7 +265,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$description = $this->getExtension('Atom')->getDescription();
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
}
|
||||
}
|
||||
|
||||
if (!$enclosure) {
|
||||
if (! $enclosure) {
|
||||
$enclosure = $this->getExtension('Atom')->getEnclosure();
|
||||
}
|
||||
|
||||
|
@ -324,7 +325,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$id = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/guid)');
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
$id = $this->getExtension('DublinCore')->getId();
|
||||
}
|
||||
|
||||
|
@ -332,7 +333,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$id = $this->getExtension('Atom')->getId();
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
if ($this->getPermalink()) {
|
||||
$id = $this->getPermalink();
|
||||
} elseif ($this->getTitle()) {
|
||||
|
@ -355,7 +356,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
*/
|
||||
public function getLink($index = 0)
|
||||
{
|
||||
if (!array_key_exists('links', $this->data)) {
|
||||
if (! array_key_exists('links', $this->data)) {
|
||||
$this->getLinks();
|
||||
}
|
||||
|
||||
|
@ -386,7 +387,7 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$list = $this->xpath->query($this->xpathQueryRdf . '//rss:link');
|
||||
}
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$links = $this->getExtension('Atom')->getLinks();
|
||||
} else {
|
||||
foreach ($list as $link) {
|
||||
|
@ -470,15 +471,15 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$title = $this->xpath->evaluate('string(' . $this->xpathQueryRdf . '/rss:title)');
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = $this->getExtension('DublinCore')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = $this->getExtension('Atom')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
@ -500,15 +501,15 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
|
||||
$commentcount = $this->getExtension('Slash')->getCommentCount();
|
||||
|
||||
if (!$commentcount) {
|
||||
if (! $commentcount) {
|
||||
$commentcount = $this->getExtension('Thread')->getCommentCount();
|
||||
}
|
||||
|
||||
if (!$commentcount) {
|
||||
if (! $commentcount) {
|
||||
$commentcount = $this->getExtension('Atom')->getCommentCount();
|
||||
}
|
||||
|
||||
if (!$commentcount) {
|
||||
if (! $commentcount) {
|
||||
$commentcount = null;
|
||||
}
|
||||
|
||||
|
@ -536,11 +537,11 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
$commentlink = $this->xpath->evaluate('string(' . $this->xpathQueryRss . '/comments)');
|
||||
}
|
||||
|
||||
if (!$commentlink) {
|
||||
if (! $commentlink) {
|
||||
$commentlink = $this->getExtension('Atom')->getCommentLink();
|
||||
}
|
||||
|
||||
if (!$commentlink) {
|
||||
if (! $commentlink) {
|
||||
$commentlink = null;
|
||||
}
|
||||
|
||||
|
@ -562,15 +563,15 @@ class Rss extends AbstractEntry implements EntryInterface
|
|||
|
||||
$commentfeedlink = $this->getExtension('WellFormedWeb')->getCommentFeedLink();
|
||||
|
||||
if (!$commentfeedlink) {
|
||||
if (! $commentfeedlink) {
|
||||
$commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rss');
|
||||
}
|
||||
|
||||
if (!$commentfeedlink) {
|
||||
if (! $commentfeedlink) {
|
||||
$commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rdf');
|
||||
}
|
||||
|
||||
if (!$commentfeedlink) {
|
||||
if (! $commentfeedlink) {
|
||||
$commentfeedlink = null;
|
||||
}
|
||||
|
||||
|
|
16
web/vendor/zendframework/zend-feed/src/Reader/Exception/InvalidHttpClientException.php
vendored
Normal file
16
web/vendor/zendframework/zend-feed/src/Reader/Exception/InvalidHttpClientException.php
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Exception;
|
||||
|
||||
use Zend\Feed\Exception;
|
||||
|
||||
class InvalidHttpClientException extends Exception\InvalidArgumentException implements ExceptionInterface
|
||||
{
|
||||
}
|
|
@ -135,18 +135,18 @@ abstract class AbstractEntry
|
|||
if ($type === Reader\Reader::TYPE_RSS_10
|
||||
|| $type === Reader\Reader::TYPE_RSS_090
|
||||
) {
|
||||
$this->setXpathPrefix('//rss:item[' . ($this->entryKey + 1) . ']');
|
||||
$this->setXpathPrefix('//rss:item[' . ((int)$this->entryKey + 1) . ']');
|
||||
return $this;
|
||||
}
|
||||
|
||||
if ($type === Reader\Reader::TYPE_ATOM_10
|
||||
|| $type === Reader\Reader::TYPE_ATOM_03
|
||||
) {
|
||||
$this->setXpathPrefix('//atom:entry[' . ($this->entryKey + 1) . ']');
|
||||
$this->setXpathPrefix('//atom:entry[' . ((int)$this->entryKey + 1) . ']');
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->setXpathPrefix('//item[' . ($this->entryKey + 1) . ']');
|
||||
$this->setXpathPrefix('//item[' . ((int)$this->entryKey + 1) . ']');
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -186,7 +186,7 @@ abstract class AbstractEntry
|
|||
*/
|
||||
public function getXpath()
|
||||
{
|
||||
if (!$this->xpath) {
|
||||
if (! $this->xpath) {
|
||||
$this->setXpath(new DOMXPath($this->getDomDocument()));
|
||||
}
|
||||
return $this->xpath;
|
||||
|
|
|
@ -51,7 +51,7 @@ class Entry extends Extension\AbstractEntry
|
|||
$authors = [];
|
||||
$list = $this->getXpath()->query($this->getXpathPrefix() . '//atom:author');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
/**
|
||||
* TODO: Limit query to feed level els only!
|
||||
*/
|
||||
|
@ -61,7 +61,7 @@ class Entry extends Extension\AbstractEntry
|
|||
if ($list->length) {
|
||||
foreach ($list as $author) {
|
||||
$author = $this->getAuthorFromElement($author);
|
||||
if (!empty($author)) {
|
||||
if (! empty($author)) {
|
||||
$authors[] = $author;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class Entry extends Extension\AbstractEntry
|
|||
}
|
||||
}
|
||||
|
||||
if (!$content) {
|
||||
if (! $content) {
|
||||
$content = $this->getDescription();
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ class Entry extends Extension\AbstractEntry
|
|||
*/
|
||||
protected function collectXhtml($xhtml, $prefix)
|
||||
{
|
||||
if (!empty($prefix)) {
|
||||
if (! empty($prefix)) {
|
||||
$prefix = $prefix . ':';
|
||||
}
|
||||
$matches = [
|
||||
|
@ -147,7 +147,7 @@ class Entry extends Extension\AbstractEntry
|
|||
"/<\/" . $prefix . "div>\s*$/"
|
||||
];
|
||||
$xhtml = preg_replace($matches, '', $xhtml);
|
||||
if (!empty($prefix)) {
|
||||
if (! empty($prefix)) {
|
||||
$xhtml = preg_replace("/(<[\/]?)" . $prefix . "([a-zA-Z]+)/", '$1$2', $xhtml);
|
||||
}
|
||||
return $xhtml;
|
||||
|
@ -222,7 +222,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:summary)');
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:id)');
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
if ($this->getPermalink()) {
|
||||
$id = $this->getPermalink();
|
||||
} elseif ($this->getTitle()) {
|
||||
|
@ -304,11 +304,11 @@ class Entry extends Extension\AbstractEntry
|
|||
. ')'
|
||||
);
|
||||
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
$baseUrl = $this->getXpath()->evaluate('string(//@xml:base[1])');
|
||||
}
|
||||
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
$baseUrl = null;
|
||||
}
|
||||
|
||||
|
@ -325,7 +325,7 @@ class Entry extends Extension\AbstractEntry
|
|||
*/
|
||||
public function getLink($index = 0)
|
||||
{
|
||||
if (!array_key_exists('links', $this->data)) {
|
||||
if (! array_key_exists('links', $this->data)) {
|
||||
$this->getLinks();
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:title)');
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
@ -554,10 +554,10 @@ class Entry extends Extension\AbstractEntry
|
|||
*/
|
||||
protected function absolutiseUri($link)
|
||||
{
|
||||
if (!Uri::factory($link)->isAbsolute()) {
|
||||
if (! Uri::factory($link)->isAbsolute()) {
|
||||
if ($this->getBaseUrl() !== null) {
|
||||
$link = $this->getBaseUrl() . $link;
|
||||
if (!Uri::factory($link)->isValid()) {
|
||||
if (! Uri::factory($link)->isValid()) {
|
||||
$link = null;
|
||||
}
|
||||
}
|
||||
|
@ -623,11 +623,11 @@ class Entry extends Extension\AbstractEntry
|
|||
$prefixAtom03 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_03);
|
||||
$prefixAtom10 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_10);
|
||||
if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_03)
|
||||
|| !empty($prefixAtom03)) {
|
||||
|| ! empty($prefixAtom03)) {
|
||||
return Reader\Reader::TYPE_ATOM_03;
|
||||
}
|
||||
if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_10)
|
||||
|| !empty($prefixAtom10)) {
|
||||
|| ! empty($prefixAtom10)) {
|
||||
return Reader\Reader::TYPE_ATOM_10;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ class Feed extends Extension\AbstractFeed
|
|||
if ($list->length) {
|
||||
foreach ($list as $author) {
|
||||
$author = $this->getAuthorFromElement($author);
|
||||
if (!empty($author)) {
|
||||
if (! empty($author)) {
|
||||
$authors[] = $author;
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$copyright = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:rights)');
|
||||
}
|
||||
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$description = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:subtitle)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ class Feed extends Extension\AbstractFeed
|
|||
// TODO: Add uri support
|
||||
$generator = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:generator)');
|
||||
|
||||
if (!$generator) {
|
||||
if (! $generator) {
|
||||
$generator = null;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$id = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:id)');
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
if ($this->getLink()) {
|
||||
$id = $this->getLink();
|
||||
} elseif ($this->getTitle()) {
|
||||
|
@ -247,11 +247,11 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$language = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:lang)');
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = $this->xpath->evaluate('string(//@xml:lang[1])');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$imageUrl = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:logo)');
|
||||
|
||||
if (!$imageUrl) {
|
||||
if (! $imageUrl) {
|
||||
$image = null;
|
||||
} else {
|
||||
$image = ['uri' => $imageUrl];
|
||||
|
@ -297,7 +297,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$baseUrl = $this->xpath->evaluate('string(//@xml:base[1])');
|
||||
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
$baseUrl = null;
|
||||
}
|
||||
$this->data['baseUrl'] = $baseUrl;
|
||||
|
@ -394,7 +394,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$title = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:title)');
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
@ -482,10 +482,10 @@ class Feed extends Extension\AbstractFeed
|
|||
*/
|
||||
protected function absolutiseUri($link)
|
||||
{
|
||||
if (!Uri::factory($link)->isAbsolute()) {
|
||||
if (! Uri::factory($link)->isAbsolute()) {
|
||||
if ($this->getBaseUrl() !== null) {
|
||||
$link = $this->getBaseUrl() . $link;
|
||||
if (!Uri::factory($link)->isValid()) {
|
||||
if (! Uri::factory($link)->isValid()) {
|
||||
$link = null;
|
||||
}
|
||||
}
|
||||
|
@ -523,12 +523,12 @@ class Feed extends Extension\AbstractFeed
|
|||
$prefixAtom03 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_03);
|
||||
$prefixAtom10 = $dom->lookupPrefix(Reader\Reader::NAMESPACE_ATOM_10);
|
||||
if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_10)
|
||||
|| !empty($prefixAtom10)
|
||||
|| ! empty($prefixAtom10)
|
||||
) {
|
||||
return Reader\Reader::TYPE_ATOM_10;
|
||||
}
|
||||
if ($dom->isDefaultNamespace(Reader\Reader::NAMESPACE_ATOM_03)
|
||||
|| !empty($prefixAtom03)
|
||||
|| ! empty($prefixAtom03)
|
||||
) {
|
||||
return Reader\Reader::TYPE_ATOM_03;
|
||||
}
|
||||
|
|
|
@ -47,13 +47,13 @@ class Entry extends Extension\AbstractEntry
|
|||
$authors = [];
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:creator');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:creator');
|
||||
}
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:publisher');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:publisher');
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:subject');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:subject');
|
||||
}
|
||||
|
||||
|
@ -133,11 +133,11 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:description)');
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:description)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:identifier)');
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
$id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:identifier)');
|
||||
}
|
||||
|
||||
|
@ -181,11 +181,11 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:title)');
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:title)');
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ class Entry extends Extension\AbstractEntry
|
|||
$d = null;
|
||||
$date = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:date)');
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:date)');
|
||||
}
|
||||
|
||||
|
|
|
@ -47,13 +47,13 @@ class Feed extends Extension\AbstractFeed
|
|||
$authors = [];
|
||||
$list = $this->getXpath()->query('//dc11:creator');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->query('//dc10:creator');
|
||||
}
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->query('//dc11:publisher');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->query('//dc10:publisher');
|
||||
}
|
||||
}
|
||||
|
@ -89,11 +89,11 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$copyright = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:rights)');
|
||||
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
$copyright = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:rights)');
|
||||
}
|
||||
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
|
@ -115,11 +115,11 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:description)');
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:description)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:identifier)');
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
$id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:identifier)');
|
||||
}
|
||||
|
||||
|
@ -163,11 +163,11 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$language = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:language)');
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:language)');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
|
@ -189,11 +189,11 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:title)');
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:title)');
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$d = null;
|
||||
$date = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:date)');
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:date)');
|
||||
}
|
||||
|
||||
|
@ -242,7 +242,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:subject');
|
||||
|
||||
if (!$list->length) {
|
||||
if (! $list->length) {
|
||||
$list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:subject');
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$author = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)');
|
||||
|
||||
if (!$author) {
|
||||
if (! $author) {
|
||||
$author = null;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$block = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)');
|
||||
|
||||
if (!$block) {
|
||||
if (! $block) {
|
||||
$block = null;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$duration = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:duration)');
|
||||
|
||||
if (!$duration) {
|
||||
if (! $duration) {
|
||||
$duration = null;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$explicit = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)');
|
||||
|
||||
if (!$explicit) {
|
||||
if (! $explicit) {
|
||||
$explicit = null;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$keywords = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)');
|
||||
|
||||
if (!$keywords) {
|
||||
if (! $keywords) {
|
||||
$keywords = null;
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$subtitle = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)');
|
||||
|
||||
if (!$subtitle) {
|
||||
if (! $subtitle) {
|
||||
$subtitle = null;
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$summary = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)');
|
||||
|
||||
if (!$summary) {
|
||||
if (! $summary) {
|
||||
$summary = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$author = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)');
|
||||
|
||||
if (!$author) {
|
||||
if (! $author) {
|
||||
$author = null;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$block = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)');
|
||||
|
||||
if (!$block) {
|
||||
if (! $block) {
|
||||
$block = null;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$children = [];
|
||||
|
||||
foreach ($node->childNodes as $childNode) {
|
||||
if (!($childNode instanceof DOMText)) {
|
||||
if (! ($childNode instanceof DOMText)) {
|
||||
$children[$childNode->getAttribute('text')] = null;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ class Feed extends Extension\AbstractFeed
|
|||
}
|
||||
}
|
||||
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
$categories = null;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$explicit = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)');
|
||||
|
||||
if (!$explicit) {
|
||||
if (! $explicit) {
|
||||
$explicit = null;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$image = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:image/@href)');
|
||||
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
$image = null;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$keywords = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)');
|
||||
|
||||
if (!$keywords) {
|
||||
if (! $keywords) {
|
||||
$keywords = null;
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$newFeedUrl = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:new-feed-url)');
|
||||
|
||||
if (!$newFeedUrl) {
|
||||
if (! $newFeedUrl) {
|
||||
$newFeedUrl = null;
|
||||
}
|
||||
|
||||
|
@ -206,13 +206,13 @@ class Feed extends Extension\AbstractFeed
|
|||
$email = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:email)');
|
||||
$name = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:name)');
|
||||
|
||||
if (!empty($email)) {
|
||||
if (! empty($email)) {
|
||||
$owner = $email . (empty($name) ? '' : ' (' . $name . ')');
|
||||
} elseif (!empty($name)) {
|
||||
} elseif (! empty($name)) {
|
||||
$owner = $name;
|
||||
}
|
||||
|
||||
if (!$owner) {
|
||||
if (! $owner) {
|
||||
$owner = null;
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$subtitle = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)');
|
||||
|
||||
if (!$subtitle) {
|
||||
if (! $subtitle) {
|
||||
$subtitle = null;
|
||||
}
|
||||
|
||||
|
@ -256,7 +256,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$summary = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)');
|
||||
|
||||
if (!$summary) {
|
||||
if (! $summary) {
|
||||
$summary = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class Entry extends Extension\AbstractEntry
|
|||
$stringParade = $this->getData($name);
|
||||
$hitParade = [];
|
||||
|
||||
if (!empty($stringParade)) {
|
||||
if (! empty($stringParade)) {
|
||||
$stringParade = explode(',', $stringParade);
|
||||
|
||||
foreach ($stringParade as $hit) {
|
||||
|
@ -78,7 +78,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$comments = $this->getData($name, 'string');
|
||||
|
||||
if (!$comments) {
|
||||
if (! $comments) {
|
||||
$this->data[$name] = null;
|
||||
return $this->data[$name];
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$data = $this->xpath->evaluate($type . '(' . $this->getXpathPrefix() . '/slash10:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
if (! $data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,7 @@ class Feed extends Extension\AbstractFeed
|
|||
return $period;
|
||||
default:
|
||||
throw new Reader\Exception\InvalidArgumentException("Feed specified invalid update period: '$period'."
|
||||
. " Must be one of hourly, daily, weekly or yearly"
|
||||
);
|
||||
. " Must be one of hourly, daily, weekly or yearly");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +53,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$name = 'updateFrequency';
|
||||
$freq = $this->getData($name, 'number');
|
||||
|
||||
if (!$freq || $freq < 1) {
|
||||
if (! $freq || $freq < 1) {
|
||||
$this->data[$name] = 1;
|
||||
return 1;
|
||||
}
|
||||
|
@ -72,7 +71,7 @@ class Feed extends Extension\AbstractFeed
|
|||
$name = 'updateFrequency';
|
||||
$freq = $this->getData($name, 'number');
|
||||
|
||||
if (!$freq || $freq < 1) {
|
||||
if (! $freq || $freq < 1) {
|
||||
$this->data[$name] = 1;
|
||||
$freq = 1;
|
||||
}
|
||||
|
@ -130,7 +129,7 @@ class Feed extends Extension\AbstractFeed
|
|||
|
||||
$data = $this->xpath->evaluate($type . '(' . $this->getXpathPrefix() . '/syn10:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
if (! $data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$data = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/thread10:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
if (! $data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class Entry extends Extension\AbstractEntry
|
|||
|
||||
$data = $this->xpath->evaluate('string(' . $this->getXpathPrefix() . '/wfw:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
if (! $data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class ExtensionManager implements ExtensionManagerInterface
|
|||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (!method_exists($this->pluginManager, $method)) {
|
||||
if (! method_exists($this->pluginManager, $method)) {
|
||||
throw new Exception\BadMethodCallException(sprintf(
|
||||
'Method by name of %s does not exist in %s',
|
||||
$method,
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
namespace Zend\Feed\Reader;
|
||||
|
||||
use Zend\ServiceManager\AbstractPluginManager;
|
||||
use Zend\ServiceManager\Exception\InvalidServiceException;
|
||||
use Zend\ServiceManager\Factory\InvokableFactory;
|
||||
|
||||
/**
|
||||
* Plugin manager implementation for feed reader extensions based on the
|
||||
|
@ -18,36 +20,119 @@ use Zend\ServiceManager\AbstractPluginManager;
|
|||
* Validation checks that we have an Extension\AbstractEntry or
|
||||
* Extension\AbstractFeed.
|
||||
*/
|
||||
class ExtensionPluginManager extends AbstractPluginManager
|
||||
class ExtensionPluginManager extends AbstractPluginManager implements ExtensionManagerInterface
|
||||
{
|
||||
/**
|
||||
* Default set of extension classes
|
||||
* Aliases for default set of extension classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $invokableClasses = [
|
||||
'atomentry' => 'Zend\Feed\Reader\Extension\Atom\Entry',
|
||||
'atomfeed' => 'Zend\Feed\Reader\Extension\Atom\Feed',
|
||||
'contententry' => 'Zend\Feed\Reader\Extension\Content\Entry',
|
||||
'creativecommonsentry' => 'Zend\Feed\Reader\Extension\CreativeCommons\Entry',
|
||||
'creativecommonsfeed' => 'Zend\Feed\Reader\Extension\CreativeCommons\Feed',
|
||||
'dublincoreentry' => 'Zend\Feed\Reader\Extension\DublinCore\Entry',
|
||||
'dublincorefeed' => 'Zend\Feed\Reader\Extension\DublinCore\Feed',
|
||||
'podcastentry' => 'Zend\Feed\Reader\Extension\Podcast\Entry',
|
||||
'podcastfeed' => 'Zend\Feed\Reader\Extension\Podcast\Feed',
|
||||
'slashentry' => 'Zend\Feed\Reader\Extension\Slash\Entry',
|
||||
'syndicationfeed' => 'Zend\Feed\Reader\Extension\Syndication\Feed',
|
||||
'threadentry' => 'Zend\Feed\Reader\Extension\Thread\Entry',
|
||||
'wellformedwebentry' => 'Zend\Feed\Reader\Extension\WellFormedWeb\Entry',
|
||||
protected $aliases = [
|
||||
'atomentry' => Extension\Atom\Entry::class,
|
||||
'atomEntry' => Extension\Atom\Entry::class,
|
||||
'AtomEntry' => Extension\Atom\Entry::class,
|
||||
'Atom\Entry' => Extension\Atom\Entry::class,
|
||||
'atomfeed' => Extension\Atom\Feed::class,
|
||||
'atomFeed' => Extension\Atom\Feed::class,
|
||||
'AtomFeed' => Extension\Atom\Feed::class,
|
||||
'Atom\Feed' => Extension\Atom\Feed::class,
|
||||
'contententry' => Extension\Content\Entry::class,
|
||||
'contentEntry' => Extension\Content\Entry::class,
|
||||
'ContentEntry' => Extension\Content\Entry::class,
|
||||
'Content\Entry' => Extension\Content\Entry::class,
|
||||
'creativecommonsentry' => Extension\CreativeCommons\Entry::class,
|
||||
'creativeCommonsEntry' => Extension\CreativeCommons\Entry::class,
|
||||
'CreativeCommonsEntry' => Extension\CreativeCommons\Entry::class,
|
||||
'CreativeCommons\Entry' => Extension\CreativeCommons\Entry::class,
|
||||
'creativecommonsfeed' => Extension\CreativeCommons\Feed::class,
|
||||
'creativeCommonsFeed' => Extension\CreativeCommons\Feed::class,
|
||||
'CreativeCommonsFeed' => Extension\CreativeCommons\Feed::class,
|
||||
'CreativeCommons\Feed' => Extension\CreativeCommons\Feed::class,
|
||||
'dublincoreentry' => Extension\DublinCore\Entry::class,
|
||||
'dublinCoreEntry' => Extension\DublinCore\Entry::class,
|
||||
'DublinCoreEntry' => Extension\DublinCore\Entry::class,
|
||||
'DublinCore\Entry' => Extension\DublinCore\Entry::class,
|
||||
'dublincorefeed' => Extension\DublinCore\Feed::class,
|
||||
'dublinCoreFeed' => Extension\DublinCore\Feed::class,
|
||||
'DublinCoreFeed' => Extension\DublinCore\Feed::class,
|
||||
'DublinCore\Feed' => Extension\DublinCore\Feed::class,
|
||||
'podcastentry' => Extension\Podcast\Entry::class,
|
||||
'podcastEntry' => Extension\Podcast\Entry::class,
|
||||
'PodcastEntry' => Extension\Podcast\Entry::class,
|
||||
'Podcast\Entry' => Extension\Podcast\Entry::class,
|
||||
'podcastfeed' => Extension\Podcast\Feed::class,
|
||||
'podcastFeed' => Extension\Podcast\Feed::class,
|
||||
'PodcastFeed' => Extension\Podcast\Feed::class,
|
||||
'Podcast\Feed' => Extension\Podcast\Feed::class,
|
||||
'slashentry' => Extension\Slash\Entry::class,
|
||||
'slashEntry' => Extension\Slash\Entry::class,
|
||||
'SlashEntry' => Extension\Slash\Entry::class,
|
||||
'Slash\Entry' => Extension\Slash\Entry::class,
|
||||
'syndicationfeed' => Extension\Syndication\Feed::class,
|
||||
'syndicationFeed' => Extension\Syndication\Feed::class,
|
||||
'SyndicationFeed' => Extension\Syndication\Feed::class,
|
||||
'Syndication\Feed' => Extension\Syndication\Feed::class,
|
||||
'threadentry' => Extension\Thread\Entry::class,
|
||||
'threadEntry' => Extension\Thread\Entry::class,
|
||||
'ThreadEntry' => Extension\Thread\Entry::class,
|
||||
'Thread\Entry' => Extension\Thread\Entry::class,
|
||||
'wellformedwebentry' => Extension\WellFormedWeb\Entry::class,
|
||||
'wellFormedWebEntry' => Extension\WellFormedWeb\Entry::class,
|
||||
'WellFormedWebEntry' => Extension\WellFormedWeb\Entry::class,
|
||||
'WellFormedWeb\Entry' => Extension\WellFormedWeb\Entry::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Do not share instances
|
||||
* Factories for default set of extension classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $factories = [
|
||||
Extension\Atom\Entry::class => InvokableFactory::class,
|
||||
Extension\Atom\Feed::class => InvokableFactory::class,
|
||||
Extension\Content\Entry::class => InvokableFactory::class,
|
||||
Extension\CreativeCommons\Entry::class => InvokableFactory::class,
|
||||
Extension\CreativeCommons\Feed::class => InvokableFactory::class,
|
||||
Extension\DublinCore\Entry::class => InvokableFactory::class,
|
||||
Extension\DublinCore\Feed::class => InvokableFactory::class,
|
||||
Extension\Podcast\Entry::class => InvokableFactory::class,
|
||||
Extension\Podcast\Feed::class => InvokableFactory::class,
|
||||
Extension\Slash\Entry::class => InvokableFactory::class,
|
||||
Extension\Syndication\Feed::class => InvokableFactory::class,
|
||||
Extension\Thread\Entry::class => InvokableFactory::class,
|
||||
Extension\WellFormedWeb\Entry::class => InvokableFactory::class,
|
||||
// Legacy (v2) due to alias resolution; canonical form of resolved
|
||||
// alias is used to look up the factory, while the non-normalized
|
||||
// resolved alias is used as the requested name passed to the factory.
|
||||
'zendfeedreaderextensionatomentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionatomfeed' => InvokableFactory::class,
|
||||
'zendfeedreaderextensioncontententry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensioncreativecommonsentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensioncreativecommonsfeed' => InvokableFactory::class,
|
||||
'zendfeedreaderextensiondublincoreentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensiondublincorefeed' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionpodcastentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionpodcastfeed' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionslashentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionsyndicationfeed' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionthreadentry' => InvokableFactory::class,
|
||||
'zendfeedreaderextensionwellformedwebentry' => InvokableFactory::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Do not share instances (v2)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $shareByDefault = false;
|
||||
|
||||
/**
|
||||
* Do not share instances (v3)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $sharedByDefault = false;
|
||||
|
||||
/**
|
||||
* Validate the plugin
|
||||
*
|
||||
|
@ -57,7 +142,7 @@ class ExtensionPluginManager extends AbstractPluginManager
|
|||
* @return void
|
||||
* @throws Exception\InvalidArgumentException if invalid
|
||||
*/
|
||||
public function validatePlugin($plugin)
|
||||
public function validate($plugin)
|
||||
{
|
||||
if ($plugin instanceof Extension\AbstractEntry
|
||||
|| $plugin instanceof Extension\AbstractFeed
|
||||
|
@ -66,7 +151,7 @@ class ExtensionPluginManager extends AbstractPluginManager
|
|||
return;
|
||||
}
|
||||
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
throw new InvalidServiceException(sprintf(
|
||||
'Plugin of type %s is invalid; must implement %s\Extension\AbstractFeed '
|
||||
. 'or %s\Extension\AbstractEntry',
|
||||
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
|
||||
|
@ -74,4 +159,26 @@ class ExtensionPluginManager extends AbstractPluginManager
|
|||
__NAMESPACE__
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the plugin (v2)
|
||||
*
|
||||
* @param mixed $plugin
|
||||
* @return void
|
||||
* @throws Exception\InvalidArgumentException if invalid
|
||||
*/
|
||||
public function validatePlugin($plugin)
|
||||
{
|
||||
try {
|
||||
$this->validate($plugin);
|
||||
} catch (InvalidServiceException $e) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Plugin of type %s is invalid; must implement %s\Extension\AbstractFeed '
|
||||
. 'or %s\Extension\AbstractEntry',
|
||||
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
|
||||
__NAMESPACE__,
|
||||
__NAMESPACE__
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -282,8 +282,10 @@ abstract class AbstractFeed implements FeedInterface
|
|||
if (in_array($extension, $all['core'])) {
|
||||
continue;
|
||||
}
|
||||
if (!$manager->has($extension)) {
|
||||
throw new Exception\RuntimeException(sprintf('Unable to load extension "%s"; cannot find class', $extension));
|
||||
if (! $manager->has($extension)) {
|
||||
throw new Exception\RuntimeException(
|
||||
sprintf('Unable to load extension "%s"; cannot find class', $extension)
|
||||
);
|
||||
}
|
||||
$plugin = $manager->get($extension);
|
||||
$plugin->setDomDocument($this->getDomDocument());
|
||||
|
|
|
@ -92,7 +92,7 @@ class Atom extends AbstractFeed
|
|||
|
||||
$copyright = $this->getExtension('Atom')->getCopyright();
|
||||
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ class Atom extends AbstractFeed
|
|||
/**
|
||||
* Get the feed creation date
|
||||
*
|
||||
* @return string|null
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ class Atom extends AbstractFeed
|
|||
|
||||
$dateCreated = $this->getExtension('Atom')->getDateCreated();
|
||||
|
||||
if (!$dateCreated) {
|
||||
if (! $dateCreated) {
|
||||
$dateCreated = null;
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ class Atom extends AbstractFeed
|
|||
/**
|
||||
* Get the feed modification date
|
||||
*
|
||||
* @return string|null
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ class Atom extends AbstractFeed
|
|||
|
||||
$dateModified = $this->getExtension('Atom')->getDateModified();
|
||||
|
||||
if (!$dateModified) {
|
||||
if (! $dateModified) {
|
||||
$dateModified = null;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ class Atom extends AbstractFeed
|
|||
|
||||
$description = $this->getExtension('Atom')->getDescription();
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -226,11 +226,11 @@ class Atom extends AbstractFeed
|
|||
|
||||
$language = $this->getExtension('Atom')->getLanguage();
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = $this->xpath->evaluate('string(//@xml:lang[1])');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,14 +41,14 @@ interface FeedInterface extends Iterator, Countable
|
|||
/**
|
||||
* Get the feed creation date
|
||||
*
|
||||
* @return string|null
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getDateCreated();
|
||||
|
||||
/**
|
||||
* Get the feed modification date
|
||||
*
|
||||
* @return string|null
|
||||
* @return \DateTime|null
|
||||
*/
|
||||
public function getDateModified();
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class Rss extends AbstractFeed
|
|||
|
||||
$authors = [];
|
||||
$authorsDc = $this->getExtension('DublinCore')->getAuthors();
|
||||
if (!empty($authorsDc)) {
|
||||
if (! empty($authorsDc)) {
|
||||
foreach ($authorsDc as $author) {
|
||||
$authors[] = [
|
||||
'name' => $author['name']
|
||||
|
@ -153,7 +153,7 @@ class Rss extends AbstractFeed
|
|||
$copyright = $this->xpath->evaluate('string(/rss/channel/copyright)');
|
||||
}
|
||||
|
||||
if (!$copyright && $this->getExtension('DublinCore') !== null) {
|
||||
if (! $copyright && $this->getExtension('DublinCore') !== null) {
|
||||
$copyright = $this->getExtension('DublinCore')->getCopyright();
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ class Rss extends AbstractFeed
|
|||
$copyright = $this->getExtension('Atom')->getCopyright();
|
||||
}
|
||||
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ class Rss extends AbstractFeed
|
|||
/**
|
||||
* Get the feed creation date
|
||||
*
|
||||
* @return string|null
|
||||
* @return DateTime|null
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ class Rss extends AbstractFeed
|
|||
if ($this->getType() !== Reader\Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Reader\Reader::TYPE_RSS_090) {
|
||||
$dateModified = $this->xpath->evaluate('string(/rss/channel/pubDate)');
|
||||
if (!$dateModified) {
|
||||
if (! $dateModified) {
|
||||
$dateModified = $this->xpath->evaluate('string(/rss/channel/lastBuildDate)');
|
||||
}
|
||||
if ($dateModified) {
|
||||
|
@ -217,7 +217,8 @@ class Rss extends AbstractFeed
|
|||
'Could not load date due to unrecognised'
|
||||
.' format (should follow RFC 822 or 2822):'
|
||||
. $e->getMessage(),
|
||||
0, $e
|
||||
0,
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -226,15 +227,15 @@ class Rss extends AbstractFeed
|
|||
}
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getExtension('DublinCore')->getDate();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = $this->getExtension('Atom')->getDateModified();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = null;
|
||||
}
|
||||
|
||||
|
@ -277,7 +278,8 @@ class Rss extends AbstractFeed
|
|||
'Could not load date due to unrecognised'
|
||||
.' format (should follow RFC 822 or 2822):'
|
||||
. $e->getMessage(),
|
||||
0, $e
|
||||
0,
|
||||
$e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +288,7 @@ class Rss extends AbstractFeed
|
|||
}
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
if (! $date) {
|
||||
$date = null;
|
||||
}
|
||||
|
||||
|
@ -313,7 +315,7 @@ class Rss extends AbstractFeed
|
|||
$description = $this->xpath->evaluate('string(/rdf:RDF/rss:channel/rss:description)');
|
||||
}
|
||||
|
||||
if (!$description && $this->getExtension('DublinCore') !== null) {
|
||||
if (! $description && $this->getExtension('DublinCore') !== null) {
|
||||
$description = $this->getExtension('DublinCore')->getDescription();
|
||||
}
|
||||
|
||||
|
@ -321,7 +323,7 @@ class Rss extends AbstractFeed
|
|||
$description = $this->getExtension('Atom')->getDescription();
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
if (! $description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
|
@ -348,7 +350,7 @@ class Rss extends AbstractFeed
|
|||
$id = $this->xpath->evaluate('string(/rss/channel/guid)');
|
||||
}
|
||||
|
||||
if (!$id && $this->getExtension('DublinCore') !== null) {
|
||||
if (! $id && $this->getExtension('DublinCore') !== null) {
|
||||
$id = $this->getExtension('DublinCore')->getId();
|
||||
}
|
||||
|
||||
|
@ -356,7 +358,7 @@ class Rss extends AbstractFeed
|
|||
$id = $this->getExtension('Atom')->getId();
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if (! $id) {
|
||||
if ($this->getLink()) {
|
||||
$id = $this->getLink();
|
||||
} elseif ($this->getTitle()) {
|
||||
|
@ -443,7 +445,7 @@ class Rss extends AbstractFeed
|
|||
$language = $this->xpath->evaluate('string(/rss/channel/language)');
|
||||
}
|
||||
|
||||
if (!$language && $this->getExtension('DublinCore') !== null) {
|
||||
if (! $language && $this->getExtension('DublinCore') !== null) {
|
||||
$language = $this->getExtension('DublinCore')->getLanguage();
|
||||
}
|
||||
|
||||
|
@ -451,11 +453,11 @@ class Rss extends AbstractFeed
|
|||
$language = $this->getExtension('Atom')->getLanguage();
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = $this->xpath->evaluate('string(//@xml:lang[1])');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
if (! $language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
|
@ -486,7 +488,7 @@ class Rss extends AbstractFeed
|
|||
$link = $this->getExtension('Atom')->getLink();
|
||||
}
|
||||
|
||||
if (!$link) {
|
||||
if (! $link) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
|
@ -535,7 +537,7 @@ class Rss extends AbstractFeed
|
|||
$generator = $this->xpath->evaluate('string(/rss/channel/generator)');
|
||||
}
|
||||
|
||||
if (!$generator) {
|
||||
if (! $generator) {
|
||||
if ($this->getType() !== Reader\Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Reader\Reader::TYPE_RSS_090) {
|
||||
$generator = $this->xpath->evaluate('string(/rss/channel/atom:generator)');
|
||||
|
@ -548,7 +550,7 @@ class Rss extends AbstractFeed
|
|||
$generator = $this->getExtension('Atom')->getGenerator();
|
||||
}
|
||||
|
||||
if (!$generator) {
|
||||
if (! $generator) {
|
||||
$generator = null;
|
||||
}
|
||||
|
||||
|
@ -575,15 +577,15 @@ class Rss extends AbstractFeed
|
|||
$title = $this->xpath->evaluate('string(/rdf:RDF/rss:channel/rss:title)');
|
||||
}
|
||||
|
||||
if (!$title && $this->getExtension('DublinCore') !== null) {
|
||||
if (! $title && $this->getExtension('DublinCore') !== null) {
|
||||
$title = $this->getExtension('DublinCore')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = $this->getExtension('Atom')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
if (! $title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,14 +41,14 @@ class FeedSet extends ArrayObject
|
|||
{
|
||||
foreach ($links as $link) {
|
||||
if (strtolower($link->getAttribute('rel')) !== 'alternate'
|
||||
|| !$link->getAttribute('type') || !$link->getAttribute('href')) {
|
||||
|| ! $link->getAttribute('type') || ! $link->getAttribute('href')) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($this->rss) && $link->getAttribute('type') == 'application/rss+xml') {
|
||||
if (! isset($this->rss) && $link->getAttribute('type') == 'application/rss+xml') {
|
||||
$this->rss = $this->absolutiseUri(trim($link->getAttribute('href')), $uri);
|
||||
} elseif (!isset($this->atom) && $link->getAttribute('type') == 'application/atom+xml') {
|
||||
} elseif (! isset($this->atom) && $link->getAttribute('type') == 'application/atom+xml') {
|
||||
$this->atom = $this->absolutiseUri(trim($link->getAttribute('href')), $uri);
|
||||
} elseif (!isset($this->rdf) && $link->getAttribute('type') == 'application/rdf+xml') {
|
||||
} elseif (! isset($this->rdf) && $link->getAttribute('type') == 'application/rdf+xml') {
|
||||
$this->rdf = $this->absolutiseUri(trim($link->getAttribute('href')), $uri);
|
||||
}
|
||||
$this[] = new static([
|
||||
|
@ -61,33 +61,73 @@ class FeedSet extends ArrayObject
|
|||
|
||||
/**
|
||||
* Attempt to turn a relative URI into an absolute URI
|
||||
*
|
||||
* @param string $link
|
||||
* @param string $uri OPTIONAL
|
||||
* @return string|null absolutised link or null if invalid
|
||||
*/
|
||||
protected function absolutiseUri($link, $uri = null)
|
||||
{
|
||||
$linkUri = Uri::factory($link);
|
||||
if (!$linkUri->isAbsolute() or !$linkUri->isValid()) {
|
||||
if ($uri !== null) {
|
||||
$uri = Uri::factory($uri);
|
||||
|
||||
if ($link[0] !== '/') {
|
||||
$link = $uri->getPath() . '/' . $link;
|
||||
}
|
||||
|
||||
$link = sprintf(
|
||||
'%s://%s/%s',
|
||||
($uri->getScheme() ?: 'http'),
|
||||
$uri->getHost(),
|
||||
$this->canonicalizePath($link)
|
||||
);
|
||||
|
||||
if (!Uri::factory($link)->isValid()) {
|
||||
$link = null;
|
||||
}
|
||||
}
|
||||
if ($linkUri->isAbsolute()) {
|
||||
// invalid absolute link can not be recovered
|
||||
return $linkUri->isValid() ? $link : null;
|
||||
}
|
||||
|
||||
$scheme = 'http';
|
||||
if ($uri !== null) {
|
||||
$uri = Uri::factory($uri);
|
||||
$scheme = $uri->getScheme() ?: $scheme;
|
||||
}
|
||||
|
||||
if ($linkUri->getHost()) {
|
||||
$link = $this->resolveSchemeRelativeUri($link, $scheme);
|
||||
} elseif ($uri !== null) {
|
||||
$link = $this->resolveRelativeUri($link, $scheme, $uri->getHost(), $uri->getPath());
|
||||
}
|
||||
|
||||
if (! Uri::factory($link)->isValid()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves scheme relative link to absolute
|
||||
*
|
||||
* @param string $link
|
||||
* @param string $scheme
|
||||
* @return string
|
||||
*/
|
||||
private function resolveSchemeRelativeUri($link, $scheme)
|
||||
{
|
||||
$link = ltrim($link, '/');
|
||||
return sprintf('%s://%s', $scheme, $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves relative link to absolute
|
||||
*
|
||||
* @param string $link
|
||||
* @param string $scheme
|
||||
* @param string $host
|
||||
* @param string $uriPath
|
||||
* @return string
|
||||
*/
|
||||
private function resolveRelativeUri($link, $scheme, $host, $uriPath)
|
||||
{
|
||||
if ($link[0] !== '/') {
|
||||
$link = $uriPath . '/' . $link;
|
||||
}
|
||||
return sprintf(
|
||||
'%s://%s/%s',
|
||||
$scheme,
|
||||
$host,
|
||||
$this->canonicalizePath($link)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Canonicalize relative path
|
||||
*/
|
||||
|
@ -117,8 +157,8 @@ class FeedSet extends ArrayObject
|
|||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
if ($offset == 'feed' && !$this->offsetExists('feed')) {
|
||||
if (!$this->offsetExists('href')) {
|
||||
if ($offset == 'feed' && ! $this->offsetExists('feed')) {
|
||||
if (! $this->offsetExists('href')) {
|
||||
return;
|
||||
}
|
||||
$feed = Reader::import($this->offsetGet('href'));
|
||||
|
|
33
web/vendor/zendframework/zend-feed/src/Reader/Http/HeaderAwareClientInterface.php
vendored
Normal file
33
web/vendor/zendframework/zend-feed/src/Reader/Http/HeaderAwareClientInterface.php
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
interface HeaderAwareClientInterface extends ClientInterface
|
||||
{
|
||||
/**
|
||||
* Allow specifying headers to use when fetching a feed.
|
||||
*
|
||||
* Headers MUST be in the format:
|
||||
*
|
||||
* <code>
|
||||
* [
|
||||
* 'header-name' => [
|
||||
* 'header',
|
||||
* 'values'
|
||||
* ]
|
||||
* ]
|
||||
* </code>
|
||||
*
|
||||
* @param string $uri
|
||||
* @param array $headers
|
||||
* @return HeaderAwareResponseInterface
|
||||
*/
|
||||
public function get($uri, array $headers = []);
|
||||
}
|
28
web/vendor/zendframework/zend-feed/src/Reader/Http/HeaderAwareResponseInterface.php
vendored
Normal file
28
web/vendor/zendframework/zend-feed/src/Reader/Http/HeaderAwareResponseInterface.php
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
interface HeaderAwareResponseInterface extends ResponseInterface
|
||||
{
|
||||
/**
|
||||
* Retrieve a header (as a single line) from the response.
|
||||
*
|
||||
* Header name lookups MUST be case insensitive.
|
||||
*
|
||||
* Since the only header values the feed reader consumes are singular
|
||||
* in nature, this method is expected to return a string, and not
|
||||
* an array of values.
|
||||
*
|
||||
* @param string $name Header name to retrieve.
|
||||
* @param mixed $default Default value to use if header is not present.
|
||||
* @return string
|
||||
*/
|
||||
public function getHeaderLine($name, $default = null);
|
||||
}
|
68
web/vendor/zendframework/zend-feed/src/Reader/Http/Psr7ResponseDecorator.php
vendored
Normal file
68
web/vendor/zendframework/zend-feed/src/Reader/Http/Psr7ResponseDecorator.php
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as Psr7ResponseInterface;
|
||||
|
||||
/**
|
||||
* ResponseInterface wrapper for a PSR-7 response.
|
||||
*/
|
||||
class Psr7ResponseDecorator implements HeaderAwareResponseInterface
|
||||
{
|
||||
/**
|
||||
* @var Psr7ResponseInterface
|
||||
*/
|
||||
private $decoratedResponse;
|
||||
|
||||
/**
|
||||
* @param Psr7ResponseInterface $response
|
||||
*/
|
||||
public function __construct(Psr7ResponseInterface $response)
|
||||
{
|
||||
$this->decoratedResponse = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the original PSR-7 response being decorated.
|
||||
*
|
||||
* @return Psr7ResponseInterface
|
||||
*/
|
||||
public function getDecoratedResponse()
|
||||
{
|
||||
return $this->decoratedResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
return (string) $this->decoratedResponse->getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->decoratedResponse->getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getHeaderLine($name, $default = null)
|
||||
{
|
||||
if (! $this->decoratedResponse->hasHeader($name)) {
|
||||
return $default;
|
||||
}
|
||||
return $this->decoratedResponse->getHeaderLine($name);
|
||||
}
|
||||
}
|
175
web/vendor/zendframework/zend-feed/src/Reader/Http/Response.php
vendored
Normal file
175
web/vendor/zendframework/zend-feed/src/Reader/Http/Response.php
vendored
Normal file
|
@ -0,0 +1,175 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
use Zend\Feed\Reader\Exception;
|
||||
|
||||
class Response implements HeaderAwareResponseInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $body;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $headers;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $statusCode;
|
||||
|
||||
/**
|
||||
* @param int $statusCode
|
||||
* @param string|object $body
|
||||
* @param array $headers
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function __construct($statusCode, $body = '', array $headers = [])
|
||||
{
|
||||
$this->validateStatusCode($statusCode);
|
||||
$this->validateBody($body);
|
||||
$this->validateHeaders($headers);
|
||||
|
||||
$this->statusCode = (int) $statusCode;
|
||||
$this->body = (string) $body;
|
||||
$this->headers = $this->normalizeHeaders($headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getBody()
|
||||
{
|
||||
return $this->body;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getHeaderLine($name, $default = null)
|
||||
{
|
||||
$normalizedName = strtolower($name);
|
||||
return isset($this->headers[$normalizedName])
|
||||
? $this->headers[$normalizedName]
|
||||
: $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that we have a status code argument that will work for our context.
|
||||
*
|
||||
* @param mixed $body
|
||||
* @throws Exception\InvalidArgumentException for arguments not castable
|
||||
* to integer HTTP status codes.
|
||||
*/
|
||||
private function validateStatusCode($statusCode)
|
||||
{
|
||||
if (! is_numeric($statusCode)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects a numeric status code; received %s',
|
||||
__CLASS__,
|
||||
(is_object($statusCode) ? get_class($statusCode) : gettype($statusCode))
|
||||
));
|
||||
}
|
||||
|
||||
if (100 > $statusCode || 599 < $statusCode) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects an integer status code between 100 and 599 inclusive; received %s',
|
||||
__CLASS__,
|
||||
$statusCode
|
||||
));
|
||||
}
|
||||
|
||||
if (intval($statusCode) != $statusCode) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects an integer status code; received %s',
|
||||
__CLASS__,
|
||||
$statusCode
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that we have a body argument that will work for our context.
|
||||
*
|
||||
* @param mixed $body
|
||||
* @throws Exception\InvalidArgumentException for arguments not castable
|
||||
* to strings.
|
||||
*/
|
||||
private function validateBody($body)
|
||||
{
|
||||
if (is_string($body)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_object($body) && method_exists($body, '__toString')) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects a string body, or an object that can cast to string; received %s',
|
||||
__CLASS__,
|
||||
(is_object($body) ? get_class($body) : gettype($body))
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate header values.
|
||||
*
|
||||
* @param array $headers
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
private function validateHeaders(array $headers)
|
||||
{
|
||||
foreach ($headers as $name => $value) {
|
||||
if (! is_string($name) || is_numeric($name) || empty($name)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Header names provided to %s must be non-empty, non-numeric strings; received %s',
|
||||
__CLASS__,
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
if (! is_string($value) && ! is_numeric($value)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Individual header values provided to %s must be a string or numeric; received %s for header %s',
|
||||
__CLASS__,
|
||||
(is_object($value) ? get_class($value) : gettype($value)),
|
||||
$name
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize header names to lowercase.
|
||||
*
|
||||
* @param array $headers
|
||||
* @return array
|
||||
*/
|
||||
private function normalizeHeaders(array $headers)
|
||||
{
|
||||
$normalized = [];
|
||||
foreach ($headers as $name => $value) {
|
||||
$normalized[strtolower($name)] = $value;
|
||||
}
|
||||
return $normalized;
|
||||
}
|
||||
}
|
118
web/vendor/zendframework/zend-feed/src/Reader/Http/ZendHttpClientDecorator.php
vendored
Normal file
118
web/vendor/zendframework/zend-feed/src/Reader/Http/ZendHttpClientDecorator.php
vendored
Normal file
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Reader\Http;
|
||||
|
||||
use Zend\Http\Client as ZendHttpClient;
|
||||
use Zend\Http\Headers;
|
||||
use Zend\Feed\Reader\Exception;
|
||||
|
||||
class ZendHttpClientDecorator implements HeaderAwareClientInterface
|
||||
{
|
||||
/**
|
||||
* @var ZendHttpClient
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @param ZendHttpClient $client
|
||||
*/
|
||||
public function __construct(ZendHttpClient $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ZendHttpClient
|
||||
*/
|
||||
public function getDecoratedClient()
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get($uri, array $headers = [])
|
||||
{
|
||||
$this->client->resetParameters();
|
||||
$this->client->setMethod('GET');
|
||||
$this->client->setHeaders(new Headers());
|
||||
$this->client->setUri($uri);
|
||||
if (! empty($headers)) {
|
||||
$this->injectHeaders($headers);
|
||||
}
|
||||
$response = $this->client->send();
|
||||
|
||||
return new Response(
|
||||
$response->getStatusCode(),
|
||||
$response->getBody(),
|
||||
$this->prepareResponseHeaders($response->getHeaders())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject header values into the client.
|
||||
*
|
||||
* @param array $headerValues
|
||||
*/
|
||||
private function injectHeaders(array $headerValues)
|
||||
{
|
||||
$headers = $this->client->getRequest()->getHeaders();
|
||||
foreach ($headerValues as $name => $values) {
|
||||
if (! is_string($name) || is_numeric($name) || empty($name)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Header names provided to %s::get must be non-empty, non-numeric strings; received %s',
|
||||
__CLASS__,
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
if (! is_array($values)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Header values provided to %s::get must be arrays of values; received %s',
|
||||
__CLASS__,
|
||||
(is_object($values) ? get_class($values) : gettype($values))
|
||||
));
|
||||
}
|
||||
|
||||
foreach ($values as $value) {
|
||||
if (! is_string($value) && ! is_numeric($value)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Individual header values provided to %s::get must be strings or numbers; '
|
||||
. 'received %s for header %s',
|
||||
__CLASS__,
|
||||
(is_object($value) ? get_class($value) : gettype($value)),
|
||||
$name
|
||||
));
|
||||
}
|
||||
|
||||
$headers->addHeaderLine($name, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize headers to use with HeaderAwareResponseInterface.
|
||||
*
|
||||
* Ensures multi-value headers are represented as a single string, via
|
||||
* comma concatenation.
|
||||
*
|
||||
* @param Headers $headers
|
||||
* @return array
|
||||
*/
|
||||
private function prepareResponseHeaders(Headers $headers)
|
||||
{
|
||||
$normalized = [];
|
||||
foreach ($headers->toArray() as $name => $value) {
|
||||
$normalized[$name] = is_array($value) ? implode(', ', $value) : $value;
|
||||
}
|
||||
return $normalized;
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ use DOMXPath;
|
|||
use Zend\Cache\Storage\StorageInterface as CacheStorage;
|
||||
use Zend\Http as ZendHttp;
|
||||
use Zend\Stdlib\ErrorHandler;
|
||||
use Zend\Feed\Reader\Exception\InvalidHttpClientException;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -57,7 +58,7 @@ class Reader implements ReaderImportInterface
|
|||
/**
|
||||
* HTTP client object to use for retrieving feeds
|
||||
*
|
||||
* @var ZendHttp\Client
|
||||
* @var Http\ClientInterface
|
||||
*/
|
||||
protected static $httpClient = null;
|
||||
|
||||
|
@ -117,23 +118,30 @@ class Reader implements ReaderImportInterface
|
|||
*
|
||||
* Sets the HTTP client object to use for retrieving the feeds.
|
||||
*
|
||||
* @param ZendHttp\Client $httpClient
|
||||
* @param ZendHttp\Client | Http\ClientInterface $httpClient
|
||||
* @return void
|
||||
*/
|
||||
public static function setHttpClient(ZendHttp\Client $httpClient)
|
||||
public static function setHttpClient($httpClient)
|
||||
{
|
||||
if ($httpClient instanceof ZendHttp\Client) {
|
||||
$httpClient = new Http\ZendHttpClientDecorator($httpClient);
|
||||
}
|
||||
|
||||
if (! $httpClient instanceof Http\ClientInterface) {
|
||||
throw new InvalidHttpClientException();
|
||||
}
|
||||
static::$httpClient = $httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the HTTP client object. If none is set, a new ZendHttp\Client will be used.
|
||||
*
|
||||
* @return ZendHttp\Client
|
||||
* @return Http\ClientInterface
|
||||
*/
|
||||
public static function getHttpClient()
|
||||
{
|
||||
if (!static::$httpClient instanceof ZendHttp\Client) {
|
||||
static::$httpClient = new ZendHttp\Client();
|
||||
if (! static::$httpClient) {
|
||||
static::$httpClient = new Http\ZendHttpClientDecorator(new ZendHttp\Client());
|
||||
}
|
||||
|
||||
return static::$httpClient;
|
||||
|
@ -189,17 +197,16 @@ class Reader implements ReaderImportInterface
|
|||
*/
|
||||
public static function import($uri, $etag = null, $lastModified = null)
|
||||
{
|
||||
$cache = self::getCache();
|
||||
$client = self::getHttpClient();
|
||||
$client->resetParameters();
|
||||
$headers = new ZendHttp\Headers();
|
||||
$client->setHeaders($headers);
|
||||
$client->setUri($uri);
|
||||
$cache = self::getCache();
|
||||
$client = self::getHttpClient();
|
||||
$cacheId = 'Zend_Feed_Reader_' . md5($uri);
|
||||
|
||||
if (static::$httpConditionalGet && $cache) {
|
||||
$data = $cache->getItem($cacheId);
|
||||
if ($data) {
|
||||
$headers = [];
|
||||
$data = $cache->getItem($cacheId);
|
||||
if ($data && $client instanceof Http\HeaderAwareClientInterface) {
|
||||
// Only check for ETag and last modified values in the cache
|
||||
// if we have a client capable of emitting headers in the first place.
|
||||
if ($etag === null) {
|
||||
$etag = $cache->getItem($cacheId . '_etag');
|
||||
}
|
||||
|
@ -207,26 +214,31 @@ class Reader implements ReaderImportInterface
|
|||
$lastModified = $cache->getItem($cacheId . '_lastmodified');
|
||||
}
|
||||
if ($etag) {
|
||||
$headers->addHeaderLine('If-None-Match', $etag);
|
||||
$headers['If-None-Match'] = [$etag];
|
||||
}
|
||||
if ($lastModified) {
|
||||
$headers->addHeaderLine('If-Modified-Since', $lastModified);
|
||||
$headers['If-Modified-Since'] = [$lastModified];
|
||||
}
|
||||
}
|
||||
$response = $client->send();
|
||||
$response = $client->get($uri, $headers);
|
||||
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 304) {
|
||||
throw new Exception\RuntimeException('Feed failed to load, got response code ' . $response->getStatusCode());
|
||||
throw new Exception\RuntimeException(
|
||||
'Feed failed to load, got response code ' . $response->getStatusCode()
|
||||
);
|
||||
}
|
||||
if ($response->getStatusCode() == 304) {
|
||||
$responseXml = $data;
|
||||
} else {
|
||||
$responseXml = $response->getBody();
|
||||
$cache->setItem($cacheId, $responseXml);
|
||||
if ($response->getHeaders()->get('ETag')) {
|
||||
$cache->setItem($cacheId . '_etag', $response->getHeaders()->get('ETag')->getFieldValue());
|
||||
}
|
||||
if ($response->getHeaders()->get('Last-Modified')) {
|
||||
$cache->setItem($cacheId . '_lastmodified', $response->getHeaders()->get('Last-Modified')->getFieldValue());
|
||||
|
||||
if ($response instanceof Http\HeaderAwareResponseInterface) {
|
||||
if ($response->getHeaderLine('ETag', false)) {
|
||||
$cache->setItem($cacheId . '_etag', $response->getHeaderLine('ETag'));
|
||||
}
|
||||
if ($response->getHeaderLine('Last-Modified', false)) {
|
||||
$cache->setItem($cacheId . '_lastmodified', $response->getHeaderLine('Last-Modified'));
|
||||
}
|
||||
}
|
||||
}
|
||||
return static::importString($responseXml);
|
||||
|
@ -235,17 +247,21 @@ class Reader implements ReaderImportInterface
|
|||
if ($data) {
|
||||
return static::importString($data);
|
||||
}
|
||||
$response = $client->send();
|
||||
$response = $client->get($uri);
|
||||
if ((int) $response->getStatusCode() !== 200) {
|
||||
throw new Exception\RuntimeException('Feed failed to load, got response code ' . $response->getStatusCode());
|
||||
throw new Exception\RuntimeException(
|
||||
'Feed failed to load, got response code ' . $response->getStatusCode()
|
||||
);
|
||||
}
|
||||
$responseXml = $response->getBody();
|
||||
$cache->setItem($cacheId, $responseXml);
|
||||
return static::importString($responseXml);
|
||||
} else {
|
||||
$response = $client->send();
|
||||
$response = $client->get($uri);
|
||||
if ((int) $response->getStatusCode() !== 200) {
|
||||
throw new Exception\RuntimeException('Feed failed to load, got response code ' . $response->getStatusCode());
|
||||
throw new Exception\RuntimeException(
|
||||
'Feed failed to load, got response code ' . $response->getStatusCode()
|
||||
);
|
||||
}
|
||||
$reader = static::importString($response->getBody());
|
||||
$reader->setOriginalSourceUri($uri);
|
||||
|
@ -270,7 +286,7 @@ class Reader implements ReaderImportInterface
|
|||
public static function importRemoteFeed($uri, Http\ClientInterface $client)
|
||||
{
|
||||
$response = $client->get($uri);
|
||||
if (!$response instanceof Http\ResponseInterface) {
|
||||
if (! $response instanceof Http\ResponseInterface) {
|
||||
throw new Exception\RuntimeException(sprintf(
|
||||
'Did not receive a %s\Http\ResponseInterface from the provided HTTP client; received "%s"',
|
||||
__NAMESPACE__,
|
||||
|
@ -279,7 +295,9 @@ class Reader implements ReaderImportInterface
|
|||
}
|
||||
|
||||
if ((int) $response->getStatusCode() !== 200) {
|
||||
throw new Exception\RuntimeException('Feed failed to load, got response code ' . $response->getStatusCode());
|
||||
throw new Exception\RuntimeException(
|
||||
'Feed failed to load, got response code ' . $response->getStatusCode()
|
||||
);
|
||||
}
|
||||
$reader = static::importString($response->getBody());
|
||||
$reader->setOriginalSourceUri($uri);
|
||||
|
@ -297,7 +315,7 @@ class Reader implements ReaderImportInterface
|
|||
public static function importString($string)
|
||||
{
|
||||
$trimmed = trim($string);
|
||||
if (!is_string($string) || empty($trimmed)) {
|
||||
if (! is_string($string) || empty($trimmed)) {
|
||||
throw new Exception\InvalidArgumentException('Only non empty strings are allowed as input');
|
||||
}
|
||||
|
||||
|
@ -315,7 +333,7 @@ class Reader implements ReaderImportInterface
|
|||
libxml_disable_entity_loader($oldValue);
|
||||
libxml_use_internal_errors($libxmlErrflag);
|
||||
|
||||
if (!$status) {
|
||||
if (! $status) {
|
||||
// Build error message
|
||||
$error = libxml_get_last_error();
|
||||
if ($error && $error->message) {
|
||||
|
@ -371,11 +389,12 @@ class Reader implements ReaderImportInterface
|
|||
*/
|
||||
public static function findFeedLinks($uri)
|
||||
{
|
||||
$client = static::getHttpClient();
|
||||
$client->setUri($uri);
|
||||
$response = $client->send();
|
||||
$client = static::getHttpClient();
|
||||
$response = $client->get($uri);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
throw new Exception\RuntimeException("Failed to access $uri, got response code " . $response->getStatusCode());
|
||||
throw new Exception\RuntimeException(
|
||||
"Failed to access $uri, got response code " . $response->getStatusCode()
|
||||
);
|
||||
}
|
||||
$responseHtml = $response->getBody();
|
||||
$libxmlErrflag = libxml_use_internal_errors(true);
|
||||
|
@ -384,7 +403,7 @@ class Reader implements ReaderImportInterface
|
|||
$status = $dom->loadHTML(trim($responseHtml));
|
||||
libxml_disable_entity_loader($oldValue);
|
||||
libxml_use_internal_errors($libxmlErrflag);
|
||||
if (!$status) {
|
||||
if (! $status) {
|
||||
// Build error message
|
||||
$error = libxml_get_last_error();
|
||||
if ($error && $error->message) {
|
||||
|
@ -416,8 +435,8 @@ class Reader implements ReaderImportInterface
|
|||
$dom = $feed->getDomDocument();
|
||||
} elseif ($feed instanceof DOMDocument) {
|
||||
$dom = $feed;
|
||||
} elseif (is_string($feed) && !empty($feed)) {
|
||||
ErrorHandler::start(E_NOTICE|E_WARNING);
|
||||
} elseif (is_string($feed) && ! empty($feed)) {
|
||||
ErrorHandler::start(E_NOTICE | E_WARNING);
|
||||
ini_set('track_errors', 1);
|
||||
$oldValue = libxml_disable_entity_loader(true);
|
||||
$dom = new DOMDocument;
|
||||
|
@ -432,8 +451,8 @@ class Reader implements ReaderImportInterface
|
|||
libxml_disable_entity_loader($oldValue);
|
||||
ini_restore('track_errors');
|
||||
ErrorHandler::stop();
|
||||
if (!$status) {
|
||||
if (!isset($phpErrormsg)) {
|
||||
if (! $status) {
|
||||
if (! isset($phpErrormsg)) {
|
||||
if (function_exists('xdebug_is_enabled')) {
|
||||
$phpErrormsg = '(error message not available, when XDebug is running)';
|
||||
} else {
|
||||
|
@ -543,7 +562,7 @@ class Reader implements ReaderImportInterface
|
|||
*/
|
||||
public static function getExtensionManager()
|
||||
{
|
||||
if (!isset(static::$extensionManager)) {
|
||||
if (! isset(static::$extensionManager)) {
|
||||
static::setExtensionManager(new StandaloneExtensionManager());
|
||||
}
|
||||
return static::$extensionManager;
|
||||
|
@ -567,7 +586,7 @@ class Reader implements ReaderImportInterface
|
|||
}
|
||||
}
|
||||
|
||||
if (!$manager->has($feedName) && !$manager->has($entryName)) {
|
||||
if (! $manager->has($feedName) && ! $manager->has($entryName)) {
|
||||
throw new Exception\RuntimeException('Could not load extension: ' . $name
|
||||
. ' using Plugin Loader. Check prefix paths are configured and extension exists.');
|
||||
}
|
||||
|
|
16
web/vendor/zendframework/zend-feed/src/Uri.php
vendored
16
web/vendor/zendframework/zend-feed/src/Uri.php
vendored
|
@ -76,13 +76,13 @@ class Uri
|
|||
return;
|
||||
}
|
||||
|
||||
$this->scheme = isset($parsed['scheme']) ? $parsed['scheme'] : null;
|
||||
$this->host = isset($parsed['host']) ? $parsed['host'] : null;
|
||||
$this->port = isset($parsed['port']) ? $parsed['port'] : null;
|
||||
$this->user = isset($parsed['user']) ? $parsed['user'] : null;
|
||||
$this->pass = isset($parsed['pass']) ? $parsed['pass'] : null;
|
||||
$this->path = isset($parsed['path']) ? $parsed['path'] : null;
|
||||
$this->query = isset($parsed['query']) ? $parsed['query'] : null;
|
||||
$this->scheme = isset($parsed['scheme']) ? $parsed['scheme'] : null;
|
||||
$this->host = isset($parsed['host']) ? $parsed['host'] : null;
|
||||
$this->port = isset($parsed['port']) ? $parsed['port'] : null;
|
||||
$this->user = isset($parsed['user']) ? $parsed['user'] : null;
|
||||
$this->pass = isset($parsed['pass']) ? $parsed['pass'] : null;
|
||||
$this->path = isset($parsed['path']) ? $parsed['path'] : null;
|
||||
$this->query = isset($parsed['query']) ? $parsed['query'] : null;
|
||||
$this->fragment = isset($parsed['fragment']) ? $parsed['fragment'] : null;
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class Uri
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($this->scheme && !in_array($this->scheme, $this->validSchemes)) {
|
||||
if ($this->scheme && ! in_array($this->scheme, $this->validSchemes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,26 +61,29 @@ class AbstractFeed
|
|||
public function addAuthor(array $author)
|
||||
{
|
||||
// Check array values
|
||||
if (!array_key_exists('name', $author)
|
||||
if (! array_key_exists('name', $author)
|
||||
|| empty($author['name'])
|
||||
|| !is_string($author['name'])
|
||||
|| ! is_string($author['name'])
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: author array must include a "name" key with a non-empty string value');
|
||||
'Invalid parameter: author array must include a "name" key with a non-empty string value'
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($author['email'])) {
|
||||
if (empty($author['email']) || !is_string($author['email'])) {
|
||||
if (empty($author['email']) || ! is_string($author['email'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "email" array value must be a non-empty string');
|
||||
'Invalid parameter: "email" array value must be a non-empty string'
|
||||
);
|
||||
}
|
||||
}
|
||||
if (isset($author['uri'])) {
|
||||
if (empty($author['uri']) || !is_string($author['uri']) ||
|
||||
!Uri::factory($author['uri'])->isValid()
|
||||
if (empty($author['uri']) || ! is_string($author['uri']) ||
|
||||
! Uri::factory($author['uri'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI');
|
||||
'Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +117,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setCopyright($copyright)
|
||||
{
|
||||
if (empty($copyright) || !is_string($copyright)) {
|
||||
if (empty($copyright) || ! is_string($copyright)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['copyright'] = $copyright;
|
||||
|
@ -135,7 +138,7 @@ class AbstractFeed
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp'
|
||||
. ' passed as parameter');
|
||||
}
|
||||
|
@ -157,7 +160,7 @@ class AbstractFeed
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp'
|
||||
. ' passed as parameter');
|
||||
}
|
||||
|
@ -179,7 +182,7 @@ class AbstractFeed
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp'
|
||||
. ' passed as parameter');
|
||||
}
|
||||
|
@ -197,7 +200,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
if (empty($description) || !is_string($description)) {
|
||||
if (empty($description) || ! is_string($description)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['description'] = $description;
|
||||
|
@ -218,36 +221,44 @@ class AbstractFeed
|
|||
{
|
||||
if (is_array($name)) {
|
||||
$data = $name;
|
||||
if (empty($data['name']) || !is_string($data['name'])) {
|
||||
if (empty($data['name']) || ! is_string($data['name'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "name" must be a non-empty string');
|
||||
}
|
||||
$generator = ['name' => $data['name']];
|
||||
if (isset($data['version'])) {
|
||||
if (empty($data['version']) || !is_string($data['version'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "version" must be a non-empty string');
|
||||
if (empty($data['version']) || ! is_string($data['version'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "version" must be a non-empty string'
|
||||
);
|
||||
}
|
||||
$generator['version'] = $data['version'];
|
||||
}
|
||||
if (isset($data['uri'])) {
|
||||
if (empty($data['uri']) || !is_string($data['uri']) || !Uri::factory($data['uri'])->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI');
|
||||
if (empty($data['uri']) || ! is_string($data['uri']) || ! Uri::factory($data['uri'])->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$generator['uri'] = $data['uri'];
|
||||
}
|
||||
} else {
|
||||
if (empty($name) || !is_string($name)) {
|
||||
if (empty($name) || ! is_string($name)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "name" must be a non-empty string');
|
||||
}
|
||||
$generator = ['name' => $name];
|
||||
if (isset($version)) {
|
||||
if (empty($version) || !is_string($version)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "version" must be a non-empty string');
|
||||
if (empty($version) || ! is_string($version)) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "version" must be a non-empty string'
|
||||
);
|
||||
}
|
||||
$generator['version'] = $version;
|
||||
}
|
||||
if (isset($uri)) {
|
||||
if (empty($uri) || !is_string($uri) || !Uri::factory($uri)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI');
|
||||
if (empty($uri) || ! is_string($uri) || ! Uri::factory($uri)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$generator['uri'] = $uri;
|
||||
}
|
||||
|
@ -266,11 +277,15 @@ class AbstractFeed
|
|||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
if ((empty($id) || !is_string($id) || !Uri::factory($id)->isValid())
|
||||
&& !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $id)
|
||||
&& !$this->_validateTagUri($id)
|
||||
// @codingStandardsIgnoreStart
|
||||
if ((empty($id) || ! is_string($id) || ! Uri::factory($id)->isValid())
|
||||
&& ! preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $id)
|
||||
&& ! $this->_validateTagUri($id)
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
|
||||
// @codingStandardsIgnoreEnd
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: parameter must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$this->data['id'] = $id;
|
||||
|
||||
|
@ -283,9 +298,15 @@ class AbstractFeed
|
|||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _validateTagUri($id)
|
||||
{
|
||||
if (preg_match('/^tag:(?P<name>.*),(?P<date>\d{4}-?\d{0,2}-?\d{0,2}):(?P<specific>.*)(.*:)*$/', $id, $matches)) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (preg_match(
|
||||
'/^tag:(?P<name>.*),(?P<date>\d{4}-?\d{0,2}-?\d{0,2}):(?P<specific>.*)(.*:)*$/',
|
||||
$id,
|
||||
$matches
|
||||
)) {
|
||||
$dvalid = false;
|
||||
$date = $matches['date'];
|
||||
$d6 = strtotime($date);
|
||||
|
@ -319,8 +340,8 @@ class AbstractFeed
|
|||
*/
|
||||
public function setImage(array $data)
|
||||
{
|
||||
if (empty($data['uri']) || !is_string($data['uri'])
|
||||
|| !Uri::factory($data['uri'])->isValid()
|
||||
if (empty($data['uri']) || ! is_string($data['uri'])
|
||||
|| ! Uri::factory($data['uri'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter \'uri\''
|
||||
. ' must be a non-empty string and valid URI/IRI');
|
||||
|
@ -339,7 +360,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setLanguage($language)
|
||||
{
|
||||
if (empty($language) || !is_string($language)) {
|
||||
if (empty($language) || ! is_string($language)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['language'] = $language;
|
||||
|
@ -356,8 +377,10 @@ class AbstractFeed
|
|||
*/
|
||||
public function setLink($link)
|
||||
{
|
||||
if (empty($link) || !is_string($link) || !Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
|
||||
if (empty($link) || ! is_string($link) || ! Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: parameter must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$this->data['link'] = $link;
|
||||
|
||||
|
@ -374,11 +397,15 @@ class AbstractFeed
|
|||
*/
|
||||
public function setFeedLink($link, $type)
|
||||
{
|
||||
if (empty($link) || !is_string($link) || !Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "link"" must be a non-empty string and valid URI/IRI');
|
||||
if (empty($link) || ! is_string($link) || ! Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "link"" must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
if (!in_array(strtolower($type), ['rss', 'rdf', 'atom'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "type"; You must declare the type of feed the link points to, i.e. RSS, RDF or Atom');
|
||||
if (! in_array(strtolower($type), ['rss', 'rdf', 'atom'])) {
|
||||
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;
|
||||
|
||||
|
@ -394,7 +421,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
if (empty($title) || !is_string($title)) {
|
||||
if (empty($title) || ! is_string($title)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['title'] = $title;
|
||||
|
@ -411,7 +438,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setEncoding($encoding)
|
||||
{
|
||||
if (empty($encoding) || !is_string($encoding)) {
|
||||
if (empty($encoding) || ! is_string($encoding)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['encoding'] = $encoding;
|
||||
|
@ -428,7 +455,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function setBaseUrl($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "url" array value'
|
||||
. ' must be a non-empty string and valid URI/IRI');
|
||||
}
|
||||
|
@ -446,11 +473,11 @@ class AbstractFeed
|
|||
*/
|
||||
public function addHub($url)
|
||||
{
|
||||
if (empty($url) || !is_string($url) || !Uri::factory($url)->isValid()) {
|
||||
if (empty($url) || ! is_string($url) || ! Uri::factory($url)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "url" array value'
|
||||
. ' must be a non-empty string and valid URI/IRI');
|
||||
}
|
||||
if (!isset($this->data['hubs'])) {
|
||||
if (! isset($this->data['hubs'])) {
|
||||
$this->data['hubs'] = [];
|
||||
}
|
||||
$this->data['hubs'][] = $url;
|
||||
|
@ -482,21 +509,21 @@ class AbstractFeed
|
|||
*/
|
||||
public function addCategory(array $category)
|
||||
{
|
||||
if (!isset($category['term'])) {
|
||||
if (! isset($category['term'])) {
|
||||
throw new Exception\InvalidArgumentException('Each category must be an array and '
|
||||
. 'contain at least a "term" element containing the machine '
|
||||
. ' readable category name');
|
||||
}
|
||||
if (isset($category['scheme'])) {
|
||||
if (empty($category['scheme'])
|
||||
|| !is_string($category['scheme'])
|
||||
|| !Uri::factory($category['scheme'])->isValid()
|
||||
|| ! is_string($category['scheme'])
|
||||
|| ! Uri::factory($category['scheme'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('The Atom scheme or RSS domain of'
|
||||
. ' a category must be a valid URI');
|
||||
}
|
||||
}
|
||||
if (!isset($this->data['categories'])) {
|
||||
if (! isset($this->data['categories'])) {
|
||||
$this->data['categories'] = [];
|
||||
}
|
||||
$this->data['categories'][] = $category;
|
||||
|
@ -541,7 +568,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (!array_key_exists('authors', $this->data)) {
|
||||
if (! array_key_exists('authors', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['authors'];
|
||||
|
@ -554,7 +581,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getCopyright()
|
||||
{
|
||||
if (!array_key_exists('copyright', $this->data)) {
|
||||
if (! array_key_exists('copyright', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['copyright'];
|
||||
|
@ -567,7 +594,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
if (!array_key_exists('dateCreated', $this->data)) {
|
||||
if (! array_key_exists('dateCreated', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['dateCreated'];
|
||||
|
@ -580,7 +607,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
if (!array_key_exists('dateModified', $this->data)) {
|
||||
if (! array_key_exists('dateModified', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['dateModified'];
|
||||
|
@ -593,7 +620,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getLastBuildDate()
|
||||
{
|
||||
if (!array_key_exists('lastBuildDate', $this->data)) {
|
||||
if (! array_key_exists('lastBuildDate', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['lastBuildDate'];
|
||||
|
@ -606,7 +633,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (!array_key_exists('description', $this->data)) {
|
||||
if (! array_key_exists('description', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['description'];
|
||||
|
@ -619,7 +646,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getGenerator()
|
||||
{
|
||||
if (!array_key_exists('generator', $this->data)) {
|
||||
if (! array_key_exists('generator', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['generator'];
|
||||
|
@ -632,7 +659,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (!array_key_exists('id', $this->data)) {
|
||||
if (! array_key_exists('id', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['id'];
|
||||
|
@ -645,7 +672,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getImage()
|
||||
{
|
||||
if (!array_key_exists('image', $this->data)) {
|
||||
if (! array_key_exists('image', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['image'];
|
||||
|
@ -658,7 +685,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
if (!array_key_exists('language', $this->data)) {
|
||||
if (! array_key_exists('language', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['language'];
|
||||
|
@ -671,7 +698,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getLink()
|
||||
{
|
||||
if (!array_key_exists('link', $this->data)) {
|
||||
if (! array_key_exists('link', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['link'];
|
||||
|
@ -684,7 +711,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getFeedLinks()
|
||||
{
|
||||
if (!array_key_exists('feedLinks', $this->data)) {
|
||||
if (! array_key_exists('feedLinks', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['feedLinks'];
|
||||
|
@ -697,7 +724,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (!array_key_exists('title', $this->data)) {
|
||||
if (! array_key_exists('title', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['title'];
|
||||
|
@ -710,7 +737,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
if (!array_key_exists('encoding', $this->data)) {
|
||||
if (! array_key_exists('encoding', $this->data)) {
|
||||
return 'UTF-8';
|
||||
}
|
||||
return $this->data['encoding'];
|
||||
|
@ -723,7 +750,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getBaseUrl()
|
||||
{
|
||||
if (!array_key_exists('baseUrl', $this->data)) {
|
||||
if (! array_key_exists('baseUrl', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['baseUrl'];
|
||||
|
@ -736,7 +763,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getHubs()
|
||||
{
|
||||
if (!array_key_exists('hubs', $this->data)) {
|
||||
if (! array_key_exists('hubs', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['hubs'];
|
||||
|
@ -749,7 +776,7 @@ class AbstractFeed
|
|||
*/
|
||||
public function getCategories()
|
||||
{
|
||||
if (!array_key_exists('categories', $this->data)) {
|
||||
if (! array_key_exists('categories', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['categories'];
|
||||
|
@ -830,14 +857,18 @@ class AbstractFeed
|
|||
* @throws Exception\RuntimeException
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _loadExtensions()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$all = Writer::getExtensions();
|
||||
$manager = Writer::getExtensionManager();
|
||||
$exts = $all['feed'];
|
||||
foreach ($exts as $ext) {
|
||||
if (!$manager->has($ext)) {
|
||||
throw new Exception\RuntimeException(sprintf('Unable to load extension "%s"; could not resolve to class', $ext));
|
||||
if (! $manager->has($ext)) {
|
||||
throw new Exception\RuntimeException(
|
||||
sprintf('Unable to load extension "%s"; could not resolve to class', $ext)
|
||||
);
|
||||
}
|
||||
$this->extensions[$ext] = $manager->get($ext);
|
||||
$this->extensions[$ext]->setEncoding($this->getEncoding());
|
||||
|
|
|
@ -41,7 +41,7 @@ class Deleted
|
|||
*/
|
||||
public function setEncoding($encoding)
|
||||
{
|
||||
if (empty($encoding) || !is_string($encoding)) {
|
||||
if (empty($encoding) || ! is_string($encoding)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['encoding'] = $encoding;
|
||||
|
@ -56,7 +56,7 @@ class Deleted
|
|||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
if (!array_key_exists('encoding', $this->data)) {
|
||||
if (! array_key_exists('encoding', $this->data)) {
|
||||
return 'UTF-8';
|
||||
}
|
||||
return $this->data['encoding'];
|
||||
|
@ -110,7 +110,7 @@ class Deleted
|
|||
*/
|
||||
public function setReference($reference)
|
||||
{
|
||||
if (empty($reference) || !is_string($reference)) {
|
||||
if (empty($reference) || ! is_string($reference)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: reference must be a non-empty string');
|
||||
}
|
||||
$this->data['reference'] = $reference;
|
||||
|
@ -123,7 +123,7 @@ class Deleted
|
|||
*/
|
||||
public function getReference()
|
||||
{
|
||||
if (!array_key_exists('reference', $this->data)) {
|
||||
if (! array_key_exists('reference', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['reference'];
|
||||
|
@ -142,7 +142,7 @@ class Deleted
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp'
|
||||
. ' passed as parameter');
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ class Deleted
|
|||
*/
|
||||
public function getWhen()
|
||||
{
|
||||
if (!array_key_exists('when', $this->data)) {
|
||||
if (! array_key_exists('when', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['when'];
|
||||
|
@ -172,16 +172,16 @@ class Deleted
|
|||
public function setBy(array $by)
|
||||
{
|
||||
$author = [];
|
||||
if (!array_key_exists('name', $by)
|
||||
if (! array_key_exists('name', $by)
|
||||
|| empty($by['name'])
|
||||
|| !is_string($by['name'])
|
||||
|| ! is_string($by['name'])
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: author array must include a'
|
||||
. ' "name" key with a non-empty string value');
|
||||
}
|
||||
$author['name'] = $by['name'];
|
||||
if (isset($by['email'])) {
|
||||
if (empty($by['email']) || !is_string($by['email'])) {
|
||||
if (empty($by['email']) || ! is_string($by['email'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "email" array'
|
||||
. ' value must be a non-empty string');
|
||||
}
|
||||
|
@ -189,8 +189,8 @@ class Deleted
|
|||
}
|
||||
if (isset($by['uri'])) {
|
||||
if (empty($by['uri'])
|
||||
|| !is_string($by['uri'])
|
||||
|| !Uri::factory($by['uri'])->isValid()
|
||||
|| ! is_string($by['uri'])
|
||||
|| ! Uri::factory($by['uri'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "uri" array value must'
|
||||
. ' be a non-empty string and valid URI/IRI');
|
||||
|
@ -207,7 +207,7 @@ class Deleted
|
|||
*/
|
||||
public function getBy()
|
||||
{
|
||||
if (!array_key_exists('by', $this->data)) {
|
||||
if (! array_key_exists('by', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['by'];
|
||||
|
@ -228,7 +228,7 @@ class Deleted
|
|||
*/
|
||||
public function getComment()
|
||||
{
|
||||
if (!array_key_exists('comment', $this->data)) {
|
||||
if (! array_key_exists('comment', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['comment'];
|
||||
|
|
|
@ -64,26 +64,29 @@ class Entry
|
|||
public function addAuthor(array $author)
|
||||
{
|
||||
// Check array values
|
||||
if (!array_key_exists('name', $author)
|
||||
if (! array_key_exists('name', $author)
|
||||
|| empty($author['name'])
|
||||
|| !is_string($author['name'])
|
||||
|| ! is_string($author['name'])
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: author array must include a "name" key with a non-empty string value');
|
||||
'Invalid parameter: author array must include a "name" key with a non-empty string value'
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($author['email'])) {
|
||||
if (empty($author['email']) || !is_string($author['email'])) {
|
||||
if (empty($author['email']) || ! is_string($author['email'])) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "email" array value must be a non-empty string');
|
||||
'Invalid parameter: "email" array value must be a non-empty string'
|
||||
);
|
||||
}
|
||||
}
|
||||
if (isset($author['uri'])) {
|
||||
if (empty($author['uri']) || !is_string($author['uri']) ||
|
||||
!Uri::factory($author['uri'])->isValid()
|
||||
if (empty($author['uri']) || ! is_string($author['uri']) ||
|
||||
! Uri::factory($author['uri'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI');
|
||||
'Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +120,7 @@ class Entry
|
|||
*/
|
||||
public function setEncoding($encoding)
|
||||
{
|
||||
if (empty($encoding) || !is_string($encoding)) {
|
||||
if (empty($encoding) || ! is_string($encoding)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['encoding'] = $encoding;
|
||||
|
@ -132,7 +135,7 @@ class Entry
|
|||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
if (!array_key_exists('encoding', $this->data)) {
|
||||
if (! array_key_exists('encoding', $this->data)) {
|
||||
return 'UTF-8';
|
||||
}
|
||||
return $this->data['encoding'];
|
||||
|
@ -147,7 +150,7 @@ class Entry
|
|||
*/
|
||||
public function setCopyright($copyright)
|
||||
{
|
||||
if (empty($copyright) || !is_string($copyright)) {
|
||||
if (empty($copyright) || ! is_string($copyright)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['copyright'] = $copyright;
|
||||
|
@ -164,7 +167,7 @@ class Entry
|
|||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
if (empty($content) || !is_string($content)) {
|
||||
if (empty($content) || ! is_string($content)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['content'] = $content;
|
||||
|
@ -185,8 +188,10 @@ class Entry
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp passed as parameter');
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid DateTime object or UNIX Timestamp passed as parameter'
|
||||
);
|
||||
}
|
||||
$this->data['dateCreated'] = $date;
|
||||
|
||||
|
@ -206,8 +211,10 @@ class Entry
|
|||
$date = new DateTime();
|
||||
} elseif (is_int($date)) {
|
||||
$date = new DateTime('@' . $date);
|
||||
} elseif (!$date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException('Invalid DateTime object or UNIX Timestamp passed as parameter');
|
||||
} elseif (! $date instanceof DateTime) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid DateTime object or UNIX Timestamp passed as parameter'
|
||||
);
|
||||
}
|
||||
$this->data['dateModified'] = $date;
|
||||
|
||||
|
@ -223,7 +230,7 @@ class Entry
|
|||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
if (empty($description) || !is_string($description)) {
|
||||
if (empty($description) || ! is_string($description)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['description'] = $description;
|
||||
|
@ -240,7 +247,7 @@ class Entry
|
|||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
if (empty($id) || !is_string($id)) {
|
||||
if (empty($id) || ! is_string($id)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['id'] = $id;
|
||||
|
@ -257,8 +264,10 @@ class Entry
|
|||
*/
|
||||
public function setLink($link)
|
||||
{
|
||||
if (empty($link) || !is_string($link) || !Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
|
||||
if (empty($link) || ! is_string($link) || ! Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: parameter must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$this->data['link'] = $link;
|
||||
|
||||
|
@ -274,8 +283,10 @@ class Entry
|
|||
*/
|
||||
public function setCommentCount($count)
|
||||
{
|
||||
if (!is_numeric($count) || (int) $count != $count || (int) $count < 0) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "count" must be a positive integer number or zero');
|
||||
if (! is_numeric($count) || (int) $count != $count || (int) $count < 0) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "count" must be a positive integer number or zero'
|
||||
);
|
||||
}
|
||||
$this->data['commentCount'] = (int) $count;
|
||||
|
||||
|
@ -291,8 +302,10 @@ class Entry
|
|||
*/
|
||||
public function setCommentLink($link)
|
||||
{
|
||||
if (empty($link) || !is_string($link) || !Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "link" must be a non-empty string and valid URI/IRI');
|
||||
if (empty($link) || ! is_string($link) || ! Uri::factory($link)->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "link" must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
$this->data['commentLink'] = $link;
|
||||
|
||||
|
@ -308,14 +321,16 @@ class Entry
|
|||
*/
|
||||
public function setCommentFeedLink(array $link)
|
||||
{
|
||||
if (!isset($link['uri']) || !is_string($link['uri']) || !Uri::factory($link['uri'])->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "link" must be a non-empty string and valid URI/IRI');
|
||||
if (! isset($link['uri']) || ! is_string($link['uri']) || ! Uri::factory($link['uri'])->isValid()) {
|
||||
throw new Exception\InvalidArgumentException(
|
||||
'Invalid parameter: "link" must be a non-empty string and valid URI/IRI'
|
||||
);
|
||||
}
|
||||
if (!isset($link['type']) || !in_array($link['type'], ['atom', 'rss', 'rdf'])) {
|
||||
if (! isset($link['type']) || ! in_array($link['type'], ['atom', 'rss', 'rdf'])) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: "type" must be one'
|
||||
. ' of "atom", "rss" or "rdf"');
|
||||
}
|
||||
if (!isset($this->data['commentFeedLinks'])) {
|
||||
if (! isset($this->data['commentFeedLinks'])) {
|
||||
$this->data['commentFeedLinks'] = [];
|
||||
}
|
||||
$this->data['commentFeedLinks'][] = $link;
|
||||
|
@ -349,7 +364,7 @@ class Entry
|
|||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
if (empty($title) || !is_string($title)) {
|
||||
if (empty($title) || ! is_string($title)) {
|
||||
throw new Exception\InvalidArgumentException('Invalid parameter: parameter must be a non-empty string');
|
||||
}
|
||||
$this->data['title'] = $title;
|
||||
|
@ -364,7 +379,7 @@ class Entry
|
|||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (!array_key_exists('authors', $this->data)) {
|
||||
if (! array_key_exists('authors', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['authors'];
|
||||
|
@ -377,7 +392,7 @@ class Entry
|
|||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (!array_key_exists('content', $this->data)) {
|
||||
if (! array_key_exists('content', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['content'];
|
||||
|
@ -390,7 +405,7 @@ class Entry
|
|||
*/
|
||||
public function getCopyright()
|
||||
{
|
||||
if (!array_key_exists('copyright', $this->data)) {
|
||||
if (! array_key_exists('copyright', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['copyright'];
|
||||
|
@ -403,7 +418,7 @@ class Entry
|
|||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
if (!array_key_exists('dateCreated', $this->data)) {
|
||||
if (! array_key_exists('dateCreated', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['dateCreated'];
|
||||
|
@ -416,7 +431,7 @@ class Entry
|
|||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
if (!array_key_exists('dateModified', $this->data)) {
|
||||
if (! array_key_exists('dateModified', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['dateModified'];
|
||||
|
@ -429,7 +444,7 @@ class Entry
|
|||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (!array_key_exists('description', $this->data)) {
|
||||
if (! array_key_exists('description', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['description'];
|
||||
|
@ -442,7 +457,7 @@ class Entry
|
|||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (!array_key_exists('id', $this->data)) {
|
||||
if (! array_key_exists('id', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['id'];
|
||||
|
@ -455,7 +470,7 @@ class Entry
|
|||
*/
|
||||
public function getLink()
|
||||
{
|
||||
if (!array_key_exists('link', $this->data)) {
|
||||
if (! array_key_exists('link', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['link'];
|
||||
|
@ -469,7 +484,7 @@ class Entry
|
|||
*/
|
||||
public function getLinks()
|
||||
{
|
||||
if (!array_key_exists('links', $this->data)) {
|
||||
if (! array_key_exists('links', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['links'];
|
||||
|
@ -482,7 +497,7 @@ class Entry
|
|||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (!array_key_exists('title', $this->data)) {
|
||||
if (! array_key_exists('title', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['title'];
|
||||
|
@ -495,7 +510,7 @@ class Entry
|
|||
*/
|
||||
public function getCommentCount()
|
||||
{
|
||||
if (!array_key_exists('commentCount', $this->data)) {
|
||||
if (! array_key_exists('commentCount', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['commentCount'];
|
||||
|
@ -508,7 +523,7 @@ class Entry
|
|||
*/
|
||||
public function getCommentLink()
|
||||
{
|
||||
if (!array_key_exists('commentLink', $this->data)) {
|
||||
if (! array_key_exists('commentLink', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['commentLink'];
|
||||
|
@ -522,7 +537,7 @@ class Entry
|
|||
*/
|
||||
public function getCommentFeedLinks()
|
||||
{
|
||||
if (!array_key_exists('commentFeedLinks', $this->data)) {
|
||||
if (! array_key_exists('commentFeedLinks', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['commentFeedLinks'];
|
||||
|
@ -537,21 +552,21 @@ class Entry
|
|||
*/
|
||||
public function addCategory(array $category)
|
||||
{
|
||||
if (!isset($category['term'])) {
|
||||
if (! isset($category['term'])) {
|
||||
throw new Exception\InvalidArgumentException('Each category must be an array and '
|
||||
. 'contain at least a "term" element containing the machine '
|
||||
. ' readable category name');
|
||||
}
|
||||
if (isset($category['scheme'])) {
|
||||
if (empty($category['scheme'])
|
||||
|| !is_string($category['scheme'])
|
||||
|| !Uri::factory($category['scheme'])->isValid()
|
||||
|| ! is_string($category['scheme'])
|
||||
|| ! Uri::factory($category['scheme'])->isValid()
|
||||
) {
|
||||
throw new Exception\InvalidArgumentException('The Atom scheme or RSS domain of'
|
||||
. ' a category must be a valid URI');
|
||||
}
|
||||
}
|
||||
if (!isset($this->data['categories'])) {
|
||||
if (! isset($this->data['categories'])) {
|
||||
$this->data['categories'] = [];
|
||||
}
|
||||
$this->data['categories'][] = $category;
|
||||
|
@ -581,7 +596,7 @@ class Entry
|
|||
*/
|
||||
public function getCategories()
|
||||
{
|
||||
if (!array_key_exists('categories', $this->data)) {
|
||||
if (! array_key_exists('categories', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['categories'];
|
||||
|
@ -599,10 +614,10 @@ class Entry
|
|||
*/
|
||||
public function setEnclosure(array $enclosure)
|
||||
{
|
||||
if (!isset($enclosure['uri'])) {
|
||||
if (! isset($enclosure['uri'])) {
|
||||
throw new Exception\InvalidArgumentException('Enclosure "uri" is not set');
|
||||
}
|
||||
if (!Uri::factory($enclosure['uri'])->isValid()) {
|
||||
if (! Uri::factory($enclosure['uri'])->isValid()) {
|
||||
throw new Exception\InvalidArgumentException('Enclosure "uri" is not a valid URI/IRI');
|
||||
}
|
||||
$this->data['enclosure'] = $enclosure;
|
||||
|
@ -617,7 +632,7 @@ class Entry
|
|||
*/
|
||||
public function getEnclosure()
|
||||
{
|
||||
if (!array_key_exists('enclosure', $this->data)) {
|
||||
if (! array_key_exists('enclosure', $this->data)) {
|
||||
return;
|
||||
}
|
||||
return $this->data['enclosure'];
|
||||
|
@ -752,8 +767,10 @@ class Entry
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _loadExtensions()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$all = Writer::getExtensions();
|
||||
$manager = Writer::getExtensionManager();
|
||||
$exts = $all['entry'];
|
||||
|
|
|
@ -160,5 +160,7 @@ abstract class AbstractRenderer implements RendererInterface
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
abstract protected function _appendNamespaces();
|
||||
// @codingStandardsIgnoreEnd
|
||||
}
|
||||
|
|
|
@ -52,10 +52,14 @@ class Feed extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:atom',
|
||||
'http://www.w3.org/2005/Atom');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:atom',
|
||||
'http://www.w3.org/2005/Atom'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,10 +69,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$flinks = $this->getDataContainer()->getFeedLinks();
|
||||
if (!$flinks || empty($flinks)) {
|
||||
if (! $flinks || empty($flinks)) {
|
||||
return;
|
||||
}
|
||||
foreach ($flinks as $type => $href) {
|
||||
|
@ -91,10 +97,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setHubs(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$hubs = $this->getDataContainer()->getHubs();
|
||||
if (!$hubs || empty($hubs)) {
|
||||
if (! $hubs || empty($hubs)) {
|
||||
return;
|
||||
}
|
||||
foreach ($hubs as $hubUrl) {
|
||||
|
|
|
@ -47,10 +47,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:content',
|
||||
'http://purl.org/rss/1.0/modules/content/');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:content',
|
||||
'http://purl.org/rss/1.0/modules/content/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +64,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setContent(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$content = $this->getDataContainer()->getContent();
|
||||
if (!$content) {
|
||||
if (! $content) {
|
||||
return;
|
||||
}
|
||||
$element = $dom->createElement('content:encoded');
|
||||
|
|
|
@ -47,10 +47,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:dc',
|
||||
'http://purl.org/dc/elements/1.1/');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:dc',
|
||||
'http://purl.org/dc/elements/1.1/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +64,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->getDataContainer()->getAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $data) {
|
||||
|
|
|
@ -47,10 +47,14 @@ class Feed extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:dc',
|
||||
'http://purl.org/dc/elements/1.1/');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:dc',
|
||||
'http://purl.org/dc/elements/1.1/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +64,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->getDataContainer()->getAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $data) {
|
||||
|
|
|
@ -76,7 +76,7 @@ class Entry
|
|||
*/
|
||||
public function setItunesBlock($value)
|
||||
{
|
||||
if (!ctype_alpha($value) && strlen($value) > 0) {
|
||||
if (! ctype_alpha($value) && strlen($value) > 0) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only'
|
||||
. ' contain alphabetic characters');
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class Entry
|
|||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "author" may only'
|
||||
. ' contain a maximum of 255 characters each');
|
||||
}
|
||||
if (!isset($this->data['authors'])) {
|
||||
if (! isset($this->data['authors'])) {
|
||||
$this->data['authors'] = [];
|
||||
}
|
||||
$this->data['authors'][] = $value;
|
||||
|
@ -132,9 +132,9 @@ class Entry
|
|||
public function setItunesDuration($value)
|
||||
{
|
||||
$value = (string) $value;
|
||||
if (!ctype_digit($value)
|
||||
&& !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
|
||||
&& !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
|
||||
if (! ctype_digit($value)
|
||||
&& ! preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
|
||||
&& ! preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
|
||||
) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "duration" may only'
|
||||
. ' be of a specified [[HH:]MM:]SS format');
|
||||
|
@ -152,7 +152,7 @@ class Entry
|
|||
*/
|
||||
public function setItunesExplicit($value)
|
||||
{
|
||||
if (!in_array($value, ['yes', 'no', 'clean'])) {
|
||||
if (! in_array($value, ['yes', 'no', 'clean'])) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "explicit" may only'
|
||||
. ' be one of "yes", "no" or "clean"');
|
||||
}
|
||||
|
@ -229,14 +229,14 @@ class Entry
|
|||
public function __call($method, array $params)
|
||||
{
|
||||
$point = lcfirst(substr($method, 9));
|
||||
if (!method_exists($this, 'setItunes' . ucfirst($point))
|
||||
&& !method_exists($this, 'addItunes' . ucfirst($point))
|
||||
if (! method_exists($this, 'setItunes' . ucfirst($point))
|
||||
&& ! method_exists($this, 'addItunes' . ucfirst($point))
|
||||
) {
|
||||
throw new Writer\Exception\BadMethodCallException(
|
||||
'invalid method: ' . $method
|
||||
);
|
||||
}
|
||||
if (!array_key_exists($point, $this->data)
|
||||
if (! array_key_exists($point, $this->data)
|
||||
|| empty($this->data[$point])
|
||||
) {
|
||||
return;
|
||||
|
|
|
@ -14,8 +14,6 @@ use Zend\Feed\Writer;
|
|||
use Zend\Stdlib\StringUtils;
|
||||
use Zend\Stdlib\StringWrapper\StringWrapperInterface;
|
||||
|
||||
/**
|
||||
*/
|
||||
class Feed
|
||||
{
|
||||
/**
|
||||
|
@ -79,7 +77,7 @@ class Feed
|
|||
*/
|
||||
public function setItunesBlock($value)
|
||||
{
|
||||
if (!ctype_alpha($value) && strlen($value) > 0) {
|
||||
if (! ctype_alpha($value) && strlen($value) > 0) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only'
|
||||
. ' contain alphabetic characters');
|
||||
}
|
||||
|
@ -118,7 +116,7 @@ class Feed
|
|||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "author" may only'
|
||||
. ' contain a maximum of 255 characters each');
|
||||
}
|
||||
if (!isset($this->data['authors'])) {
|
||||
if (! isset($this->data['authors'])) {
|
||||
$this->data['authors'] = [];
|
||||
}
|
||||
$this->data['authors'][] = $value;
|
||||
|
@ -134,11 +132,11 @@ class Feed
|
|||
*/
|
||||
public function setItunesCategories(array $values)
|
||||
{
|
||||
if (!isset($this->data['categories'])) {
|
||||
if (! isset($this->data['categories'])) {
|
||||
$this->data['categories'] = [];
|
||||
}
|
||||
foreach ($values as $key => $value) {
|
||||
if (!is_array($value)) {
|
||||
if (! is_array($value)) {
|
||||
if ($this->stringWrapper->strlen($value) > 255) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "category" may only'
|
||||
. ' contain a maximum of 255 characters each');
|
||||
|
@ -171,11 +169,11 @@ class Feed
|
|||
*/
|
||||
public function setItunesImage($value)
|
||||
{
|
||||
if (!Uri::factory($value)->isValid()) {
|
||||
if (! Uri::factory($value)->isValid()) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "image" may only'
|
||||
. ' be a valid URI/IRI');
|
||||
}
|
||||
if (!in_array(substr($value, -3), ['jpg', 'png'])) {
|
||||
if (! in_array(substr($value, -3), ['jpg', 'png'])) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "image" may only'
|
||||
. ' use file extension "jpg" or "png" which must be the last three'
|
||||
. ' characters of the URI (i.e. no query string or fragment)');
|
||||
|
@ -194,9 +192,9 @@ class Feed
|
|||
public function setItunesDuration($value)
|
||||
{
|
||||
$value = (string) $value;
|
||||
if (!ctype_digit($value)
|
||||
&& !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
|
||||
&& !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
|
||||
if (! ctype_digit($value)
|
||||
&& ! preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
|
||||
&& ! preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
|
||||
) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "duration" may only'
|
||||
. ' be of a specified [[HH:]MM:]SS format');
|
||||
|
@ -214,7 +212,7 @@ class Feed
|
|||
*/
|
||||
public function setItunesExplicit($value)
|
||||
{
|
||||
if (!in_array($value, ['yes', 'no', 'clean'])) {
|
||||
if (! in_array($value, ['yes', 'no', 'clean'])) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "explicit" may only'
|
||||
. ' be one of "yes", "no" or "clean"');
|
||||
}
|
||||
|
@ -254,7 +252,7 @@ class Feed
|
|||
*/
|
||||
public function setItunesNewFeedUrl($value)
|
||||
{
|
||||
if (!Uri::factory($value)->isValid()) {
|
||||
if (! Uri::factory($value)->isValid()) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: "newFeedUrl" may only'
|
||||
. ' be a valid URI/IRI');
|
||||
}
|
||||
|
@ -285,7 +283,7 @@ class Feed
|
|||
*/
|
||||
public function addItunesOwner(array $value)
|
||||
{
|
||||
if (!isset($value['name']) || !isset($value['email'])) {
|
||||
if (! isset($value['name']) || ! isset($value['email'])) {
|
||||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "owner" must'
|
||||
. ' be an array containing keys "name" and "email"');
|
||||
}
|
||||
|
@ -295,7 +293,7 @@ class Feed
|
|||
throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "owner" may only'
|
||||
. ' contain a maximum of 255 characters each for "name" and "email"');
|
||||
}
|
||||
if (!isset($this->data['owners'])) {
|
||||
if (! isset($this->data['owners'])) {
|
||||
$this->data['owners'] = [];
|
||||
}
|
||||
$this->data['owners'][] = $value;
|
||||
|
@ -347,14 +345,14 @@ class Feed
|
|||
public function __call($method, array $params)
|
||||
{
|
||||
$point = lcfirst(substr($method, 9));
|
||||
if (!method_exists($this, 'setItunes' . ucfirst($point))
|
||||
&& !method_exists($this, 'addItunes' . ucfirst($point))
|
||||
if (! method_exists($this, 'setItunes' . ucfirst($point))
|
||||
&& ! method_exists($this, 'addItunes' . ucfirst($point))
|
||||
) {
|
||||
throw new Writer\Exception\BadMethodCallException(
|
||||
'invalid method: ' . $method
|
||||
);
|
||||
}
|
||||
if (!array_key_exists($point, $this->data) || empty($this->data[$point])) {
|
||||
if (! array_key_exists($point, $this->data) || empty($this->data[$point])) {
|
||||
return;
|
||||
}
|
||||
return $this->data[$point];
|
||||
|
|
|
@ -50,10 +50,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:itunes',
|
||||
'http://www.itunes.com/dtds/podcast-1.0.dtd');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:itunes',
|
||||
'http://www.itunes.com/dtds/podcast-1.0.dtd'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,10 +67,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->getDataContainer()->getItunesAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $author) {
|
||||
|
@ -85,8 +91,10 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBlock(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$block = $this->getDataContainer()->getItunesBlock();
|
||||
if ($block === null) {
|
||||
return;
|
||||
|
@ -105,10 +113,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDuration(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$duration = $this->getDataContainer()->getItunesDuration();
|
||||
if (!$duration) {
|
||||
if (! $duration) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:duration');
|
||||
|
@ -125,8 +135,10 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setExplicit(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$explicit = $this->getDataContainer()->getItunesExplicit();
|
||||
if ($explicit === null) {
|
||||
return;
|
||||
|
@ -145,10 +157,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setKeywords(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$keywords = $this->getDataContainer()->getItunesKeywords();
|
||||
if (!$keywords || empty($keywords)) {
|
||||
if (! $keywords || empty($keywords)) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:keywords');
|
||||
|
@ -165,10 +179,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setSubtitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$subtitle = $this->getDataContainer()->getItunesSubtitle();
|
||||
if (!$subtitle) {
|
||||
if (! $subtitle) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:subtitle');
|
||||
|
@ -185,10 +201,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setSummary(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$summary = $this->getDataContainer()->getItunesSummary();
|
||||
if (!$summary) {
|
||||
if (! $summary) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:summary');
|
||||
|
|
|
@ -54,10 +54,14 @@ class Feed extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:itunes',
|
||||
'http://www.itunes.com/dtds/podcast-1.0.dtd');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:itunes',
|
||||
'http://www.itunes.com/dtds/podcast-1.0.dtd'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,10 +71,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->getDataContainer()->getItunesAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $author) {
|
||||
|
@ -89,8 +95,10 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBlock(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$block = $this->getDataContainer()->getItunesBlock();
|
||||
if ($block === null) {
|
||||
return;
|
||||
|
@ -109,14 +117,16 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$cats = $this->getDataContainer()->getItunesCategories();
|
||||
if (!$cats || empty($cats)) {
|
||||
if (! $cats || empty($cats)) {
|
||||
return;
|
||||
}
|
||||
foreach ($cats as $key => $cat) {
|
||||
if (!is_array($cat)) {
|
||||
if (! is_array($cat)) {
|
||||
$el = $dom->createElement('itunes:category');
|
||||
$el->setAttribute('text', $cat);
|
||||
$root->appendChild($el);
|
||||
|
@ -141,10 +151,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setImage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$image = $this->getDataContainer()->getItunesImage();
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:image');
|
||||
|
@ -160,10 +172,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDuration(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$duration = $this->getDataContainer()->getItunesDuration();
|
||||
if (!$duration) {
|
||||
if (! $duration) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:duration');
|
||||
|
@ -180,8 +194,10 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setExplicit(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$explicit = $this->getDataContainer()->getItunesExplicit();
|
||||
if ($explicit === null) {
|
||||
return;
|
||||
|
@ -200,10 +216,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setKeywords(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$keywords = $this->getDataContainer()->getItunesKeywords();
|
||||
if (!$keywords || empty($keywords)) {
|
||||
if (! $keywords || empty($keywords)) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:keywords');
|
||||
|
@ -220,10 +238,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setNewFeedUrl(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$url = $this->getDataContainer()->getItunesNewFeedUrl();
|
||||
if (!$url) {
|
||||
if (! $url) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:new-feed-url');
|
||||
|
@ -240,10 +260,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setOwners(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$owners = $this->getDataContainer()->getItunesOwners();
|
||||
if (!$owners || empty($owners)) {
|
||||
if (! $owners || empty($owners)) {
|
||||
return;
|
||||
}
|
||||
foreach ($owners as $owner) {
|
||||
|
@ -268,10 +290,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setSubtitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$subtitle = $this->getDataContainer()->getItunesSubtitle();
|
||||
if (!$subtitle) {
|
||||
if (! $subtitle) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:subtitle');
|
||||
|
@ -288,10 +312,12 @@ class Feed extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setSummary(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$summary = $this->getDataContainer()->getItunesSummary();
|
||||
if (!$summary) {
|
||||
if (! $summary) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('itunes:summary');
|
||||
|
|
|
@ -47,10 +47,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:slash',
|
||||
'http://purl.org/rss/1.0/modules/slash/');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:slash',
|
||||
'http://purl.org/rss/1.0/modules/slash/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +64,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentCount(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$count = $this->getDataContainer()->getCommentCount();
|
||||
if (!$count) {
|
||||
if (! $count) {
|
||||
$count = 0;
|
||||
}
|
||||
$tcount = $this->dom->createElement('slash:comments');
|
||||
|
|
|
@ -49,10 +49,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:thr',
|
||||
'http://purl.org/syndication/thread/1.0');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:thr',
|
||||
'http://purl.org/syndication/thread/1.0'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,10 +66,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$link = $this->getDataContainer()->getCommentLink();
|
||||
if (!$link) {
|
||||
if (! $link) {
|
||||
return;
|
||||
}
|
||||
$clink = $this->dom->createElement('link');
|
||||
|
@ -87,10 +93,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentFeedLinks(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$links = $this->getDataContainer()->getCommentFeedLinks();
|
||||
if (!$links || empty($links)) {
|
||||
if (! $links || empty($links)) {
|
||||
return;
|
||||
}
|
||||
foreach ($links as $link) {
|
||||
|
@ -114,8 +122,10 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentCount(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$count = $this->getDataContainer()->getCommentCount();
|
||||
if ($count === null) {
|
||||
return;
|
||||
|
|
|
@ -47,10 +47,14 @@ class Entry extends Extension\AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _appendNamespaces()
|
||||
{
|
||||
$this->getRootElement()->setAttribute('xmlns:wfw',
|
||||
'http://wellformedweb.org/CommentAPI/');
|
||||
// @codingStandardsIgnoreEnd
|
||||
$this->getRootElement()->setAttribute(
|
||||
'xmlns:wfw',
|
||||
'http://wellformedweb.org/CommentAPI/'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,10 +64,12 @@ class Entry extends Extension\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentFeedLinks(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$links = $this->getDataContainer()->getCommentFeedLinks();
|
||||
if (!$links || empty($links)) {
|
||||
if (! $links || empty($links)) {
|
||||
return;
|
||||
}
|
||||
foreach ($links as $link) {
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Zend\Feed\Writer;
|
|||
/**
|
||||
* Default implementation of ExtensionManagerInterface
|
||||
*
|
||||
* Decorator of ExtensionPluginManager.
|
||||
* Decorator for an ExtensionManagerInstance.
|
||||
*/
|
||||
class ExtensionManager implements ExtensionManagerInterface
|
||||
{
|
||||
|
@ -22,14 +22,14 @@ class ExtensionManager implements ExtensionManagerInterface
|
|||
* Constructor
|
||||
*
|
||||
* Seeds the extension manager with a plugin manager; if none provided,
|
||||
* creates an instance.
|
||||
* creates and decorates an instance of StandaloneExtensionManager.
|
||||
*
|
||||
* @param null|ExtensionPluginManager $pluginManager
|
||||
* @param null|ExtensionManagerInterface $pluginManager
|
||||
*/
|
||||
public function __construct(ExtensionPluginManager $pluginManager = null)
|
||||
public function __construct(ExtensionManagerInterface $pluginManager = null)
|
||||
{
|
||||
if (null === $pluginManager) {
|
||||
$pluginManager = new ExtensionPluginManager();
|
||||
$pluginManager = new StandaloneExtensionManager();
|
||||
}
|
||||
$this->pluginManager = $pluginManager;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class ExtensionManager implements ExtensionManagerInterface
|
|||
/**
|
||||
* Method overloading
|
||||
*
|
||||
* Proxy to composed ExtensionPluginManager instance.
|
||||
* Proxy to composed ExtensionManagerInterface instance.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
|
@ -46,7 +46,7 @@ class ExtensionManager implements ExtensionManagerInterface
|
|||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (!method_exists($this->pluginManager, $method)) {
|
||||
if (! method_exists($this->pluginManager, $method)) {
|
||||
throw new Exception\BadMethodCallException(sprintf(
|
||||
'Method by name of %s does not exist in %s',
|
||||
$method,
|
||||
|
|
|
@ -10,50 +10,129 @@
|
|||
namespace Zend\Feed\Writer;
|
||||
|
||||
use Zend\ServiceManager\AbstractPluginManager;
|
||||
use Zend\ServiceManager\Exception\InvalidServiceException;
|
||||
use Zend\ServiceManager\Factory\InvokableFactory;
|
||||
|
||||
/**
|
||||
* Plugin manager implementation for feed writer extensions
|
||||
*
|
||||
* Validation checks that we have an Entry, Feed, or Extension\AbstractRenderer.
|
||||
*/
|
||||
class ExtensionPluginManager extends AbstractPluginManager
|
||||
class ExtensionPluginManager extends AbstractPluginManager implements ExtensionManagerInterface
|
||||
{
|
||||
/**
|
||||
* Default set of extension classes
|
||||
* Aliases for default set of extension classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $invokableClasses = [
|
||||
'atomrendererfeed' => 'Zend\Feed\Writer\Extension\Atom\Renderer\Feed',
|
||||
'contentrendererentry' => 'Zend\Feed\Writer\Extension\Content\Renderer\Entry',
|
||||
'dublincorerendererentry' => 'Zend\Feed\Writer\Extension\DublinCore\Renderer\Entry',
|
||||
'dublincorerendererfeed' => 'Zend\Feed\Writer\Extension\DublinCore\Renderer\Feed',
|
||||
'itunesentry' => 'Zend\Feed\Writer\Extension\ITunes\Entry',
|
||||
'itunesfeed' => 'Zend\Feed\Writer\Extension\ITunes\Feed',
|
||||
'itunesrendererentry' => 'Zend\Feed\Writer\Extension\ITunes\Renderer\Entry',
|
||||
'itunesrendererfeed' => 'Zend\Feed\Writer\Extension\ITunes\Renderer\Feed',
|
||||
'slashrendererentry' => 'Zend\Feed\Writer\Extension\Slash\Renderer\Entry',
|
||||
'threadingrendererentry' => 'Zend\Feed\Writer\Extension\Threading\Renderer\Entry',
|
||||
'wellformedwebrendererentry' => 'Zend\Feed\Writer\Extension\WellFormedWeb\Renderer\Entry',
|
||||
protected $aliases = [
|
||||
'atomrendererfeed' => Extension\Atom\Renderer\Feed::class,
|
||||
'atomRendererFeed' => Extension\Atom\Renderer\Feed::class,
|
||||
'AtomRendererFeed' => Extension\Atom\Renderer\Feed::class,
|
||||
'AtomRenderer\Feed' => Extension\Atom\Renderer\Feed::class,
|
||||
'contentrendererentry' => Extension\Content\Renderer\Entry::class,
|
||||
'contentRendererEntry' => Extension\Content\Renderer\Entry::class,
|
||||
'ContentRendererEntry' => Extension\Content\Renderer\Entry::class,
|
||||
'ContentRenderer\Entry' => Extension\Content\Renderer\Entry::class,
|
||||
'dublincorerendererentry' => Extension\DublinCore\Renderer\Entry::class,
|
||||
'dublinCoreRendererEntry' => Extension\DublinCore\Renderer\Entry::class,
|
||||
'DublinCoreRendererEntry' => Extension\DublinCore\Renderer\Entry::class,
|
||||
'DublinCoreRenderer\Entry' => Extension\DublinCore\Renderer\Entry::class,
|
||||
'dublincorerendererfeed' => Extension\DublinCore\Renderer\Feed::class,
|
||||
'dublinCoreRendererFeed' => Extension\DublinCore\Renderer\Feed::class,
|
||||
'DublinCoreRendererFeed' => Extension\DublinCore\Renderer\Feed::class,
|
||||
'DublinCoreRenderer\Feed' => Extension\DublinCore\Renderer\Feed::class,
|
||||
'itunesentry' => Extension\ITunes\Entry::class,
|
||||
'itunesEntry' => Extension\ITunes\Entry::class,
|
||||
'iTunesEntry' => Extension\ITunes\Entry::class,
|
||||
'ItunesEntry' => Extension\ITunes\Entry::class,
|
||||
'Itunes\Entry' => Extension\ITunes\Entry::class,
|
||||
'itunesfeed' => Extension\ITunes\Feed::class,
|
||||
'itunesFeed' => Extension\ITunes\Feed::class,
|
||||
'iTunesFeed' => Extension\ITunes\Feed::class,
|
||||
'ItunesFeed' => Extension\ITunes\Feed::class,
|
||||
'Itunes\Feed' => Extension\ITunes\Feed::class,
|
||||
'itunesrendererentry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'itunesRendererEntry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'iTunesRendererEntry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'ItunesRendererEntry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'ItunesRenderer\Entry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'itunesrendererfeed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'itunesRendererFeed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'iTunesRendererFeed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'ItunesRendererFeed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'ItunesRenderer\Feed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'slashrendererentry' => Extension\Slash\Renderer\Entry::class,
|
||||
'slashRendererEntry' => Extension\Slash\Renderer\Entry::class,
|
||||
'SlashRendererEntry' => Extension\Slash\Renderer\Entry::class,
|
||||
'SlashRenderer\Entry' => Extension\Slash\Renderer\Entry::class,
|
||||
'threadingrendererentry' => Extension\Threading\Renderer\Entry::class,
|
||||
'threadingRendererEntry' => Extension\Threading\Renderer\Entry::class,
|
||||
'ThreadingRendererEntry' => Extension\Threading\Renderer\Entry::class,
|
||||
'ThreadingRenderer\Entry' => Extension\Threading\Renderer\Entry::class,
|
||||
'wellformedwebrendererentry' => Extension\WellFormedWeb\Renderer\Entry::class,
|
||||
'wellFormedWebRendererEntry' => Extension\WellFormedWeb\Renderer\Entry::class,
|
||||
'WellFormedWebRendererEntry' => Extension\WellFormedWeb\Renderer\Entry::class,
|
||||
'WellFormedWebRenderer\Entry' => Extension\WellFormedWeb\Renderer\Entry::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Do not share instances
|
||||
* Factories for default set of extension classes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $factories = [
|
||||
Extension\Atom\Renderer\Feed::class => InvokableFactory::class,
|
||||
Extension\Content\Renderer\Entry::class => InvokableFactory::class,
|
||||
Extension\DublinCore\Renderer\Entry::class => InvokableFactory::class,
|
||||
Extension\DublinCore\Renderer\Feed::class => InvokableFactory::class,
|
||||
Extension\ITunes\Entry::class => InvokableFactory::class,
|
||||
Extension\ITunes\Feed::class => InvokableFactory::class,
|
||||
Extension\ITunes\Renderer\Entry::class => InvokableFactory::class,
|
||||
Extension\ITunes\Renderer\Feed::class => InvokableFactory::class,
|
||||
Extension\Slash\Renderer\Entry::class => InvokableFactory::class,
|
||||
Extension\Threading\Renderer\Entry::class => InvokableFactory::class,
|
||||
Extension\WellFormedWeb\Renderer\Entry::class => InvokableFactory::class,
|
||||
// Legacy (v2) due to alias resolution; canonical form of resolved
|
||||
// alias is used to look up the factory, while the non-normalized
|
||||
// resolved alias is used as the requested name passed to the factory.
|
||||
'zendfeedwriterextensionatomrendererfeed' => InvokableFactory::class,
|
||||
'zendfeedwriterextensioncontentrendererentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensiondublincorerendererentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensiondublincorerendererfeed' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionitunesentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionitunesfeed' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionitunesrendererentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionitunesrendererfeed' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionslashrendererentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionthreadingrendererentry' => InvokableFactory::class,
|
||||
'zendfeedwriterextensionwellformedwebrendererentry' => InvokableFactory::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Do not share instances (v2)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $shareByDefault = false;
|
||||
|
||||
/**
|
||||
* Validate the plugin
|
||||
* Do not share instances (v3)
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $sharedByDefault = false;
|
||||
|
||||
/**
|
||||
* Validate the plugin (v3)
|
||||
*
|
||||
* Checks that the extension loaded is of a valid type.
|
||||
*
|
||||
* @param mixed $plugin
|
||||
* @return void
|
||||
* @throws Exception\InvalidArgumentException if invalid
|
||||
* @throws InvalidServiceException if invalid
|
||||
*/
|
||||
public function validatePlugin($plugin)
|
||||
public function validate($plugin)
|
||||
{
|
||||
if ($plugin instanceof Extension\AbstractRenderer) {
|
||||
// we're okay
|
||||
|
@ -70,11 +149,32 @@ class ExtensionPluginManager extends AbstractPluginManager
|
|||
return;
|
||||
}
|
||||
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
throw new InvalidServiceException(sprintf(
|
||||
'Plugin of type %s is invalid; must implement %s\Extension\RendererInterface '
|
||||
. 'or the classname must end in "Feed" or "Entry"',
|
||||
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
|
||||
__NAMESPACE__
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate plugin (v2)
|
||||
*
|
||||
* @param mixed $plugin
|
||||
* @return void
|
||||
* @throws Exception\InvalidArgumentException when invalid
|
||||
*/
|
||||
public function validatePlugin($plugin)
|
||||
{
|
||||
try {
|
||||
$this->validate($plugin);
|
||||
} catch (InvalidServiceException $e) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Plugin of type %s is invalid; must implement %s\Extension\RendererInterface '
|
||||
. 'or the classname must end in "Feed" or "Entry"',
|
||||
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
|
||||
__NAMESPACE__
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ class Feed extends AbstractFeed implements Iterator, Countable
|
|||
*/
|
||||
public function removeEntry($index)
|
||||
{
|
||||
if (!isset($this->entries[$index])) {
|
||||
if (! isset($this->entries[$index])) {
|
||||
throw new Exception\InvalidArgumentException('Undefined index: ' . $index . '. Entry does not exist.');
|
||||
}
|
||||
unset($this->entries[$index]);
|
||||
|
|
|
@ -22,7 +22,7 @@ abstract class FeedFactory
|
|||
*/
|
||||
public static function factory($data)
|
||||
{
|
||||
if (!is_array($data) && !$data instanceof Traversable) {
|
||||
if (! is_array($data) && ! $data instanceof Traversable) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects an array or Traversable argument; received "%s"',
|
||||
__METHOD__,
|
||||
|
@ -39,11 +39,11 @@ abstract class FeedFactory
|
|||
if (method_exists($feed, $method)) {
|
||||
switch ($method) {
|
||||
case 'setfeedlink':
|
||||
if (!is_array($value)) {
|
||||
if (! is_array($value)) {
|
||||
// Need an array
|
||||
break;
|
||||
}
|
||||
if (!array_key_exists('link', $value) || !array_key_exists('type', $value)) {
|
||||
if (! array_key_exists('link', $value) || ! array_key_exists('type', $value)) {
|
||||
// Need both keys to set this correctly
|
||||
break;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ abstract class FeedFactory
|
|||
*/
|
||||
protected static function createEntries($entries, Feed $feed)
|
||||
{
|
||||
if (!is_array($entries) && !$entries instanceof Traversable) {
|
||||
if (! is_array($entries) && ! $entries instanceof Traversable) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s::factory expects the "entries" value to be an array or Traversable; received "%s"',
|
||||
get_called_class(),
|
||||
|
@ -97,7 +97,7 @@ abstract class FeedFactory
|
|||
}
|
||||
|
||||
foreach ($entries as $data) {
|
||||
if (!is_array($data) && !$data instanceof Traversable && !$data instanceof Entry) {
|
||||
if (! is_array($data) && ! $data instanceof Traversable && ! $data instanceof Entry) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'%s expects an array, Traversable, or Zend\Feed\Writer\Entry argument; received "%s"',
|
||||
__METHOD__,
|
||||
|
@ -116,7 +116,7 @@ abstract class FeedFactory
|
|||
foreach ($data as $key => $value) {
|
||||
$key = static::convertKey($key);
|
||||
$method = 'set' . $key;
|
||||
if (!method_exists($entry, $method)) {
|
||||
if (! method_exists($entry, $method)) {
|
||||
continue;
|
||||
}
|
||||
$entry->$method($value);
|
||||
|
|
|
@ -146,8 +146,10 @@ class AbstractRenderer
|
|||
*/
|
||||
public function ignoreExceptions($bool = true)
|
||||
{
|
||||
if (!is_bool($bool)) {
|
||||
throw new Writer\Exception\InvalidArgumentException('Invalid parameter: $bool. Should be TRUE or FALSE (defaults to TRUE if null)');
|
||||
if (! is_bool($bool)) {
|
||||
throw new Writer\Exception\InvalidArgumentException(
|
||||
'Invalid parameter: $bool. Should be TRUE or FALSE (defaults to TRUE if null)'
|
||||
);
|
||||
}
|
||||
$this->ignoreExceptions = $bool;
|
||||
return $this;
|
||||
|
@ -213,8 +215,10 @@ class AbstractRenderer
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _loadExtensions()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
Writer\Writer::registerCoreExtensions();
|
||||
$manager = Writer\Writer::getExtensionManager();
|
||||
$all = Writer\Writer::getExtensions();
|
||||
|
|
|
@ -71,13 +71,15 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setTitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'Atom 1.0 entry elements MUST contain exactly one'
|
||||
. ' atom:title element but a title has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -98,9 +100,11 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDescription(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()) {
|
||||
return; // unless src content or base64
|
||||
}
|
||||
$subtitle = $dom->createElement('summary');
|
||||
|
@ -120,13 +124,15 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateModified(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$message = 'Atom 1.0 entry elements MUST contain exactly one'
|
||||
. ' atom:updated element but a modification date has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -149,9 +155,11 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateCreated()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateCreated()) {
|
||||
return;
|
||||
}
|
||||
$el = $dom->createElement('published');
|
||||
|
@ -169,10 +177,12 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->container->getAuthors();
|
||||
if ((!$authors || empty($authors))) {
|
||||
if ((! $authors || empty($authors))) {
|
||||
/**
|
||||
* This will actually trigger an Exception at the feed level if
|
||||
* a feed level author is not set.
|
||||
|
@ -208,10 +218,12 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setEnclosure(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$data = $this->container->getEnclosure();
|
||||
if ((!$data || empty($data))) {
|
||||
if ((! $data || empty($data))) {
|
||||
return;
|
||||
}
|
||||
$enclosure = $this->dom->createElement('link');
|
||||
|
@ -226,9 +238,11 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
$root->appendChild($enclosure);
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getLink()) {
|
||||
return;
|
||||
}
|
||||
$link = $dom->createElement('link');
|
||||
|
@ -246,16 +260,18 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setId(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getId()
|
||||
&& !$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getId()
|
||||
&& ! $this->getDataContainer()->getLink()) {
|
||||
$message = 'Atom 1.0 entry elements MUST contain exactly one '
|
||||
. 'atom:id element, or as an alternative, we can use the same '
|
||||
. 'value as atom:link however neither a suitable link nor an '
|
||||
. 'id have been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -263,17 +279,17 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
}
|
||||
}
|
||||
|
||||
if (!$this->getDataContainer()->getId()) {
|
||||
if (! $this->getDataContainer()->getId()) {
|
||||
$this->getDataContainer()->setId(
|
||||
$this->getDataContainer()->getLink()
|
||||
);
|
||||
}
|
||||
if (!Uri::factory($this->getDataContainer()->getId())->isValid()
|
||||
&& !preg_match(
|
||||
if (! Uri::factory($this->getDataContainer()->getId())->isValid()
|
||||
&& ! preg_match(
|
||||
"#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#",
|
||||
$this->getDataContainer()->getId()
|
||||
)
|
||||
&& !$this->_validateTagUri($this->getDataContainer()->getId())
|
||||
&& ! $this->_validateTagUri($this->getDataContainer()->getId())
|
||||
) {
|
||||
throw new Writer\Exception\InvalidArgumentException('Atom 1.0 IDs must be a valid URI/IRI');
|
||||
}
|
||||
|
@ -289,8 +305,10 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _validateTagUri($id)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (preg_match(
|
||||
'/^tag:(?P<name>.*),(?P<date>\d{4}-?\d{0,2}-?\d{0,2}):(?P<specific>.*)(.*:)*$/',
|
||||
$id,
|
||||
|
@ -325,23 +343,25 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setContent(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$content = $this->getDataContainer()->getContent();
|
||||
if (!$content && !$this->getDataContainer()->getLink()) {
|
||||
if (! $content && ! $this->getDataContainer()->getLink()) {
|
||||
$message = 'Atom 1.0 entry elements MUST contain exactly one '
|
||||
. 'atom:content element, or as an alternative, at least one link '
|
||||
. 'with a rel attribute of "alternate" to indicate an alternate '
|
||||
. 'method to consume the content.';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!$content) {
|
||||
if (! $content) {
|
||||
return;
|
||||
}
|
||||
$element = $dom->createElement('content');
|
||||
|
@ -356,8 +376,10 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
/**
|
||||
* Load a HTML string and attempt to normalise to XML
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _loadXhtml($content)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (class_exists('tidy', false)) {
|
||||
$tidy = new \tidy;
|
||||
$config = [
|
||||
|
@ -391,10 +413,12 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$categories = $this->getDataContainer()->getCategories();
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $cat) {
|
||||
|
@ -419,10 +443,12 @@ class Atom extends Renderer\AbstractRenderer implements Renderer\RendererInterfa
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setSource(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$source = $this->getDataContainer()->getSource();
|
||||
if (!$source) {
|
||||
if (! $source) {
|
||||
return;
|
||||
}
|
||||
$renderer = new Renderer\Feed\AtomSource($source);
|
||||
|
|
|
@ -55,9 +55,11 @@ class Deleted extends Renderer\AbstractRenderer implements Renderer\RendererInte
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setComment(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getComment()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getComment()) {
|
||||
return;
|
||||
}
|
||||
$c = $dom->createElement('at:comment');
|
||||
|
@ -74,10 +76,12 @@ class Deleted extends Renderer\AbstractRenderer implements Renderer\RendererInte
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBy(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$data = $this->container->getBy();
|
||||
if ((!$data || empty($data))) {
|
||||
if ((! $data || empty($data))) {
|
||||
return;
|
||||
}
|
||||
$author = $this->dom->createElement('at:by');
|
||||
|
|
|
@ -57,9 +57,11 @@ class AtomDeleted extends Renderer\AbstractRenderer implements Renderer\Renderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setComment(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getComment()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getComment()) {
|
||||
return;
|
||||
}
|
||||
$c = $dom->createElement('at:comment');
|
||||
|
@ -76,10 +78,12 @@ class AtomDeleted extends Renderer\AbstractRenderer implements Renderer\Renderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBy(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$data = $this->container->getBy();
|
||||
if ((!$data || empty($data))) {
|
||||
if ((! $data || empty($data))) {
|
||||
return;
|
||||
}
|
||||
$author = $this->dom->createElement('at:by');
|
||||
|
|
|
@ -71,15 +71,17 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setTitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()
|
||||
&& !$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()
|
||||
&& ! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'RSS 2.0 entry elements SHOULD contain exactly one'
|
||||
. ' title element but a title has not been set. In addition, there'
|
||||
. ' is no description as required in the absence of a title.';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -100,23 +102,25 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDescription(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()
|
||||
&& !$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()
|
||||
&& ! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'RSS 2.0 entry elements SHOULD contain exactly one'
|
||||
. ' description element but a description has not been set. In'
|
||||
. ' addition, there is no title element as required in the absence'
|
||||
. ' of a description.';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!$this->getDataContainer()->getDescription()) {
|
||||
if (! $this->getDataContainer()->getDescription()) {
|
||||
return;
|
||||
}
|
||||
$subtitle = $dom->createElement('description');
|
||||
|
@ -132,9 +136,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateModified(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -153,12 +159,14 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateCreated()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateCreated()) {
|
||||
return;
|
||||
}
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$this->getDataContainer()->setDateModified(
|
||||
$this->getDataContainer()->getDateCreated()
|
||||
);
|
||||
|
@ -172,10 +180,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->container->getAuthors();
|
||||
if ((!$authors || empty($authors))) {
|
||||
if ((! $authors || empty($authors))) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $data) {
|
||||
|
@ -198,34 +208,36 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setEnclosure(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$data = $this->container->getEnclosure();
|
||||
if ((!$data || empty($data))) {
|
||||
if ((! $data || empty($data))) {
|
||||
return;
|
||||
}
|
||||
if (!isset($data['type'])) {
|
||||
if (! isset($data['type'])) {
|
||||
$exception = new Writer\Exception\InvalidArgumentException('Enclosure "type" is not set');
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!isset($data['length'])) {
|
||||
if (! isset($data['length'])) {
|
||||
$exception = new Writer\Exception\InvalidArgumentException('Enclosure "length" is not set');
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((int) $data['length'] < 0 || !ctype_digit((string) $data['length'])) {
|
||||
if ((int) $data['length'] < 0 || ! ctype_digit((string) $data['length'])) {
|
||||
$exception = new Writer\Exception\InvalidArgumentException('Enclosure "length" must be an integer'
|
||||
. ' indicating the content\'s length in bytes');
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -246,9 +258,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getLink()) {
|
||||
return;
|
||||
}
|
||||
$link = $dom->createElement('link');
|
||||
|
@ -264,22 +278,25 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setId(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getId()
|
||||
&& !$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getId()
|
||||
&& ! $this->getDataContainer()->getLink()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$id = $dom->createElement('guid');
|
||||
$root->appendChild($id);
|
||||
if (!$this->getDataContainer()->getId()) {
|
||||
if (! $this->getDataContainer()->getId()) {
|
||||
$this->getDataContainer()->setId(
|
||||
$this->getDataContainer()->getLink());
|
||||
$this->getDataContainer()->getLink()
|
||||
);
|
||||
}
|
||||
$text = $dom->createTextNode($this->getDataContainer()->getId());
|
||||
$id->appendChild($text);
|
||||
if (!Uri::factory($this->getDataContainer()->getId())->isValid()) {
|
||||
if (! Uri::factory($this->getDataContainer()->getId())->isValid()) {
|
||||
$id->setAttribute('isPermaLink', 'false');
|
||||
}
|
||||
}
|
||||
|
@ -291,10 +308,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCommentLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$link = $this->getDataContainer()->getCommentLink();
|
||||
if (!$link) {
|
||||
if (! $link) {
|
||||
return;
|
||||
}
|
||||
$clink = $this->dom->createElement('comments');
|
||||
|
@ -310,10 +329,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$categories = $this->getDataContainer()->getCategories();
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $cat) {
|
||||
|
|
|
@ -37,8 +37,10 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLanguage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if ($this->getDataContainer()->getLanguage()) {
|
||||
$root->setAttribute('xml:lang', $this->getDataContainer()
|
||||
->getLanguage());
|
||||
|
@ -53,13 +55,15 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setTitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one'
|
||||
. ' atom:title element but a title has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -81,9 +85,11 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDescription(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()) {
|
||||
return;
|
||||
}
|
||||
$subtitle = $dom->createElement('subtitle');
|
||||
|
@ -101,13 +107,15 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateModified(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one'
|
||||
. ' atom:updated element but a modification date has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -130,11 +138,16 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getGenerator()) {
|
||||
$this->getDataContainer()->setGenerator('Zend_Feed_Writer',
|
||||
Version::VERSION, 'http://framework.zend.com');
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getGenerator()) {
|
||||
$this->getDataContainer()->setGenerator(
|
||||
'Zend_Feed_Writer',
|
||||
Version::VERSION,
|
||||
'http://framework.zend.com'
|
||||
);
|
||||
}
|
||||
|
||||
$gdata = $this->getDataContainer()->getGenerator();
|
||||
|
@ -157,9 +170,11 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getLink()) {
|
||||
return;
|
||||
}
|
||||
$link = $dom->createElement('link');
|
||||
|
@ -177,16 +192,18 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$flinks = $this->getDataContainer()->getFeedLinks();
|
||||
if (!$flinks || !array_key_exists('atom', $flinks)) {
|
||||
if (! $flinks || ! array_key_exists('atom', $flinks)) {
|
||||
$message = 'Atom 1.0 feed elements SHOULD contain one atom:link '
|
||||
. 'element with a rel attribute value of "self". This is the '
|
||||
. 'preferred URI for retrieving Atom Feed Documents representing '
|
||||
. 'this Atom feed but a feed link has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -211,10 +228,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->container->getAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
/**
|
||||
* Technically we should defer an exception until we can check
|
||||
* that all entries contain an author. If any entry is missing
|
||||
|
@ -252,16 +271,18 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setId(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getId()
|
||||
&& !$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getId()
|
||||
&& ! $this->getDataContainer()->getLink()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one '
|
||||
. 'atom:id element, or as an alternative, we can use the same '
|
||||
. 'value as atom:link however neither a suitable link nor an '
|
||||
. 'id have been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -269,9 +290,10 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
}
|
||||
}
|
||||
|
||||
if (!$this->getDataContainer()->getId()) {
|
||||
if (! $this->getDataContainer()->getId()) {
|
||||
$this->getDataContainer()->setId(
|
||||
$this->getDataContainer()->getLink());
|
||||
$this->getDataContainer()->getLink()
|
||||
);
|
||||
}
|
||||
$id = $dom->createElement('id');
|
||||
$root->appendChild($id);
|
||||
|
@ -286,10 +308,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCopyright(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$copyright = $this->getDataContainer()->getCopyright();
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
return;
|
||||
}
|
||||
$copy = $dom->createElement('rights');
|
||||
|
@ -305,10 +329,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setImage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$image = $this->getDataContainer()->getImage();
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
return;
|
||||
}
|
||||
$img = $dom->createElement('logo');
|
||||
|
@ -324,12 +350,14 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateCreated()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateCreated()) {
|
||||
return;
|
||||
}
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$this->getDataContainer()->setDateModified(
|
||||
$this->getDataContainer()->getDateCreated()
|
||||
);
|
||||
|
@ -343,10 +371,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBaseUrl(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$baseUrl = $this->getDataContainer()->getBaseUrl();
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
return;
|
||||
}
|
||||
$root->setAttribute('xml:base', $baseUrl);
|
||||
|
@ -359,10 +389,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setHubs(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$hubs = $this->getDataContainer()->getHubs();
|
||||
if (!$hubs) {
|
||||
if (! $hubs) {
|
||||
return;
|
||||
}
|
||||
foreach ($hubs as $hubUrl) {
|
||||
|
@ -380,10 +412,12 @@ class AbstractAtom extends Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$categories = $this->getDataContainer()->getCategories();
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $cat) {
|
||||
|
|
|
@ -34,7 +34,7 @@ class Atom extends AbstractAtom implements Renderer\RendererInterface
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
if (!$this->container->getEncoding()) {
|
||||
if (! $this->container->getEncoding()) {
|
||||
$this->container->setEncoding('UTF-8');
|
||||
}
|
||||
$this->dom = new DOMDocument('1.0', $this->container->getEncoding());
|
||||
|
@ -75,7 +75,7 @@ class Atom extends AbstractAtom implements Renderer\RendererInterface
|
|||
if ($entry instanceof Writer\Entry) {
|
||||
$renderer = new Renderer\Entry\Atom($entry);
|
||||
} else {
|
||||
if (!$this->dom->documentElement->hasAttribute('xmlns:at')) {
|
||||
if (! $this->dom->documentElement->hasAttribute('xmlns:at')) {
|
||||
$this->dom->documentElement->setAttribute(
|
||||
'xmlns:at',
|
||||
'http://purl.org/atompub/tombstones/1.0'
|
||||
|
|
|
@ -34,8 +34,10 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLanguage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
if ($this->getDataContainer()->getLanguage()) {
|
||||
$root->setAttribute('xml:lang', $this->getDataContainer()
|
||||
->getLanguage());
|
||||
|
@ -50,13 +52,15 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Feed\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setTitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one'
|
||||
. ' atom:title element but a title has not been set';
|
||||
$exception = new Feed\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -78,9 +82,11 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDescription(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()) {
|
||||
return;
|
||||
}
|
||||
$subtitle = $dom->createElement('subtitle');
|
||||
|
@ -98,13 +104,15 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Feed\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateModified(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one'
|
||||
. ' atom:updated element but a modification date has not been set';
|
||||
$exception = new Feed\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -127,11 +135,16 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getGenerator()) {
|
||||
$this->getDataContainer()->setGenerator('Zend_Feed_Writer',
|
||||
Version::VERSION, 'http://framework.zend.com');
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getGenerator()) {
|
||||
$this->getDataContainer()->setGenerator(
|
||||
'Zend_Feed_Writer',
|
||||
Version::VERSION,
|
||||
'http://framework.zend.com'
|
||||
);
|
||||
}
|
||||
|
||||
$gdata = $this->getDataContainer()->getGenerator();
|
||||
|
@ -154,9 +167,11 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getLink()) {
|
||||
return;
|
||||
}
|
||||
$link = $dom->createElement('link');
|
||||
|
@ -174,16 +189,18 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Feed\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$flinks = $this->getDataContainer()->getFeedLinks();
|
||||
if (!$flinks || !array_key_exists('atom', $flinks)) {
|
||||
if (! $flinks || ! array_key_exists('atom', $flinks)) {
|
||||
$message = 'Atom 1.0 feed elements SHOULD contain one atom:link '
|
||||
. 'element with a rel attribute value of "self". This is the '
|
||||
. 'preferred URI for retrieving Atom Feed Documents representing '
|
||||
. 'this Atom feed but a feed link has not been set';
|
||||
$exception = new Feed\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -208,10 +225,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->container->getAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
/**
|
||||
* Technically we should defer an exception until we can check
|
||||
* that all entries contain an author. If any entry is missing
|
||||
|
@ -249,16 +268,18 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @return void
|
||||
* @throws Feed\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setId(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getId()
|
||||
&& !$this->getDataContainer()->getLink()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getId()
|
||||
&& ! $this->getDataContainer()->getLink()) {
|
||||
$message = 'Atom 1.0 feed elements MUST contain exactly one '
|
||||
. 'atom:id element, or as an alternative, we can use the same '
|
||||
. 'value as atom:link however neither a suitable link nor an '
|
||||
. 'id have been set';
|
||||
$exception = new Feed\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -266,9 +287,10 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
}
|
||||
}
|
||||
|
||||
if (!$this->getDataContainer()->getId()) {
|
||||
if (! $this->getDataContainer()->getId()) {
|
||||
$this->getDataContainer()->setId(
|
||||
$this->getDataContainer()->getLink());
|
||||
$this->getDataContainer()->getLink()
|
||||
);
|
||||
}
|
||||
$id = $dom->createElement('id');
|
||||
$root->appendChild($id);
|
||||
|
@ -283,10 +305,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCopyright(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$copyright = $this->getDataContainer()->getCopyright();
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
return;
|
||||
}
|
||||
$copy = $dom->createElement('rights');
|
||||
|
@ -294,6 +318,7 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
$text = $dom->createTextNode($copyright);
|
||||
$copy->appendChild($text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set feed level logo (image)
|
||||
*
|
||||
|
@ -301,10 +326,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setImage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$image = $this->getDataContainer()->getImage();
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
return;
|
||||
}
|
||||
$img = $dom->createElement('logo');
|
||||
|
@ -320,12 +347,14 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateCreated()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateCreated()) {
|
||||
return;
|
||||
}
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$this->getDataContainer()->setDateModified(
|
||||
$this->getDataContainer()->getDateCreated()
|
||||
);
|
||||
|
@ -339,10 +368,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBaseUrl(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$baseUrl = $this->getDataContainer()->getBaseUrl();
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
return;
|
||||
}
|
||||
$root->setAttribute('xml:base', $baseUrl);
|
||||
|
@ -355,10 +386,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setHubs(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$hubs = $this->getDataContainer()->getHubs();
|
||||
if (!$hubs) {
|
||||
if (! $hubs) {
|
||||
return;
|
||||
}
|
||||
foreach ($hubs as $hubUrl) {
|
||||
|
@ -376,10 +409,12 @@ class AbstractAtom extends Feed\Writer\Renderer\AbstractRenderer
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$categories = $this->getDataContainer()->getCategories();
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $cat) {
|
||||
|
|
|
@ -33,7 +33,7 @@ class Source extends AbstractAtom implements Renderer\RendererInterface
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
if (!$this->container->getEncoding()) {
|
||||
if (! $this->container->getEncoding()) {
|
||||
$this->container->setEncoding('UTF-8');
|
||||
}
|
||||
$this->dom = new DOMDocument('1.0', $this->container->getEncoding());
|
||||
|
@ -71,9 +71,11 @@ class Source extends AbstractAtom implements Renderer\RendererInterface
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getGenerator()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getGenerator()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class AtomSource extends AbstractAtom implements Renderer\RendererInterface
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
if (!$this->container->getEncoding()) {
|
||||
if (! $this->container->getEncoding()) {
|
||||
$this->container->setEncoding('UTF-8');
|
||||
}
|
||||
$this->dom = new DOMDocument('1.0', $this->container->getEncoding());
|
||||
|
@ -73,9 +73,11 @@ class AtomSource extends AbstractAtom implements Renderer\RendererInterface
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getGenerator()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getGenerator()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,10 +99,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLanguage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$lang = $this->getDataContainer()->getLanguage();
|
||||
if (!$lang) {
|
||||
if (! $lang) {
|
||||
return;
|
||||
}
|
||||
$language = $dom->createElement('language');
|
||||
|
@ -118,13 +120,15 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setTitle(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getTitle()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getTitle()) {
|
||||
$message = 'RSS 2.0 feed elements MUST contain exactly one'
|
||||
. ' title element but a title has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -146,13 +150,15 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDescription(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDescription()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDescription()) {
|
||||
$message = 'RSS 2.0 feed elements MUST contain exactly one'
|
||||
. ' description element but one has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -172,9 +178,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateModified(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -193,9 +201,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getGenerator()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getGenerator()) {
|
||||
$this->getDataContainer()->setGenerator(
|
||||
'Zend_Feed_Writer',
|
||||
Version::VERSION,
|
||||
|
@ -225,14 +235,16 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLink(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$value = $this->getDataContainer()->getLink();
|
||||
if (!$value) {
|
||||
if (! $value) {
|
||||
$message = 'RSS 2.0 feed elements MUST contain exactly one'
|
||||
. ' link element but one has not been set';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -243,7 +255,7 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
$root->appendChild($link);
|
||||
$text = $dom->createTextNode($value);
|
||||
$link->appendChild($text);
|
||||
if (!Uri::factory($value)->isValid()) {
|
||||
if (! Uri::factory($value)->isValid()) {
|
||||
$link->setAttribute('isPermaLink', 'false');
|
||||
}
|
||||
}
|
||||
|
@ -255,10 +267,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setAuthors(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$authors = $this->getDataContainer()->getAuthors();
|
||||
if (!$authors || empty($authors)) {
|
||||
if (! $authors || empty($authors)) {
|
||||
return;
|
||||
}
|
||||
foreach ($authors as $data) {
|
||||
|
@ -280,10 +294,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCopyright(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$copyright = $this->getDataContainer()->getCopyright();
|
||||
if (!$copyright) {
|
||||
if (! $copyright) {
|
||||
return;
|
||||
}
|
||||
$copy = $dom->createElement('copyright');
|
||||
|
@ -300,19 +316,21 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @return void
|
||||
* @throws Writer\Exception\InvalidArgumentException
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setImage(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$image = $this->getDataContainer()->getImage();
|
||||
if (!$image) {
|
||||
if (! $image) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($image['title']) || empty($image['title'])
|
||||
|| !is_string($image['title'])
|
||||
if (! isset($image['title']) || empty($image['title'])
|
||||
|| ! is_string($image['title'])
|
||||
) {
|
||||
$message = 'RSS 2.0 feed images must include a title';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -320,13 +338,13 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($image['link']) || !is_string($image['link'])
|
||||
|| !Uri::factory($image['link'])->isValid()
|
||||
if (empty($image['link']) || ! is_string($image['link'])
|
||||
|| ! Uri::factory($image['link'])->isValid()
|
||||
) {
|
||||
$message = 'Invalid parameter: parameter \'link\''
|
||||
. ' must be a non-empty string and valid URI/IRI';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -354,11 +372,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
$img->appendChild($link);
|
||||
|
||||
if (isset($image['height'])) {
|
||||
if (!ctype_digit((string) $image['height']) || $image['height'] > 400) {
|
||||
if (! ctype_digit((string) $image['height']) || $image['height'] > 400) {
|
||||
$message = 'Invalid parameter: parameter \'height\''
|
||||
. ' must be an integer not exceeding 400';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -371,11 +389,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
$img->appendChild($height);
|
||||
}
|
||||
if (isset($image['width'])) {
|
||||
if (!ctype_digit((string) $image['width']) || $image['width'] > 144) {
|
||||
if (! ctype_digit((string) $image['width']) || $image['width'] > 144) {
|
||||
$message = 'Invalid parameter: parameter \'width\''
|
||||
. ' must be an integer not exceeding 144';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -388,11 +406,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
$img->appendChild($width);
|
||||
}
|
||||
if (isset($image['description'])) {
|
||||
if (empty($image['description']) || !is_string($image['description'])) {
|
||||
if (empty($image['description']) || ! is_string($image['description'])) {
|
||||
$message = 'Invalid parameter: parameter \'description\''
|
||||
. ' must be a non-empty string';
|
||||
$exception = new Writer\Exception\InvalidArgumentException($message);
|
||||
if (!$this->ignoreExceptions) {
|
||||
if (! $this->ignoreExceptions) {
|
||||
throw $exception;
|
||||
} else {
|
||||
$this->exceptions[] = $exception;
|
||||
|
@ -413,12 +431,14 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getDateCreated()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getDateCreated()) {
|
||||
return;
|
||||
}
|
||||
if (!$this->getDataContainer()->getDateModified()) {
|
||||
if (! $this->getDataContainer()->getDateModified()) {
|
||||
$this->getDataContainer()->setDateModified(
|
||||
$this->getDataContainer()->getDateCreated()
|
||||
);
|
||||
|
@ -432,9 +452,11 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setLastBuildDate(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
if (!$this->getDataContainer()->getLastBuildDate()) {
|
||||
// @codingStandardsIgnoreEnd
|
||||
if (! $this->getDataContainer()->getLastBuildDate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -453,10 +475,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setBaseUrl(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$baseUrl = $this->getDataContainer()->getBaseUrl();
|
||||
if (!$baseUrl) {
|
||||
if (! $baseUrl) {
|
||||
return;
|
||||
}
|
||||
$root->setAttribute('xml:base', $baseUrl);
|
||||
|
@ -469,10 +493,12 @@ class Rss extends Renderer\AbstractRenderer implements Renderer\RendererInterfac
|
|||
* @param DOMElement $root
|
||||
* @return void
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
protected function _setCategories(DOMDocument $dom, DOMElement $root)
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
$categories = $this->getDataContainer()->getCategories();
|
||||
if (!$categories) {
|
||||
if (! $categories) {
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $cat) {
|
||||
|
|
50
web/vendor/zendframework/zend-feed/src/Writer/StandaloneExtensionManager.php
vendored
Normal file
50
web/vendor/zendframework/zend-feed/src/Writer/StandaloneExtensionManager.php
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Feed\Writer;
|
||||
|
||||
class StandaloneExtensionManager implements ExtensionManagerInterface
|
||||
{
|
||||
private $extensions = [
|
||||
'Atom\Renderer\Feed' => Extension\Atom\Renderer\Feed::class,
|
||||
'Content\Renderer\Entry' => Extension\Content\Renderer\Entry::class,
|
||||
'DublinCore\Renderer\Entry' => Extension\DublinCore\Renderer\Entry::class,
|
||||
'DublinCore\Renderer\Feed' => Extension\DublinCore\Renderer\Feed::class,
|
||||
'ITunes\Entry' => Extension\ITunes\Entry::class,
|
||||
'ITunes\Feed' => Extension\ITunes\Feed::class,
|
||||
'ITunes\Renderer\Entry' => Extension\ITunes\Renderer\Entry::class,
|
||||
'ITunes\Renderer\Feed' => Extension\ITunes\Renderer\Feed::class,
|
||||
'Slash\Renderer\Entry' => Extension\Slash\Renderer\Entry::class,
|
||||
'Threading\Renderer\Entry' => Extension\Threading\Renderer\Entry::class,
|
||||
'WellFormedWeb\Renderer\Entry' => Extension\WellFormedWeb\Renderer\Entry::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Do we have the extension?
|
||||
*
|
||||
* @param string $extension
|
||||
* @return bool
|
||||
*/
|
||||
public function has($extension)
|
||||
{
|
||||
return array_key_exists($extension, $this->extensions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the extension
|
||||
*
|
||||
* @param string $extension
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($extension)
|
||||
{
|
||||
$class = $this->extensions[$extension];
|
||||
return new $class();
|
||||
}
|
||||
}
|
|
@ -76,7 +76,7 @@ class Writer
|
|||
*/
|
||||
public static function getExtensionManager()
|
||||
{
|
||||
if (!isset(static::$extensionManager)) {
|
||||
if (! isset(static::$extensionManager)) {
|
||||
static::setExtensionManager(new ExtensionManager());
|
||||
}
|
||||
return static::$extensionManager;
|
||||
|
@ -105,13 +105,16 @@ class Writer
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (!$manager->has($feedName)
|
||||
&& !$manager->has($entryName)
|
||||
&& !$manager->has($feedRendererName)
|
||||
&& !$manager->has($entryRendererName)
|
||||
if (! $manager->has($feedName)
|
||||
&& ! $manager->has($entryName)
|
||||
&& ! $manager->has($feedRendererName)
|
||||
&& ! $manager->has($entryRendererName)
|
||||
) {
|
||||
throw new Exception\RuntimeException('Could not load extension: ' . $name
|
||||
. 'using Plugin Loader. Check prefix paths are configured and extension exists.');
|
||||
throw new Exception\RuntimeException(sprintf(
|
||||
'Could not load extension "%s" using Plugin Loader. '
|
||||
. 'Check prefix paths are configured and extension exists.',
|
||||
$name
|
||||
));
|
||||
}
|
||||
if ($manager->has($feedName)) {
|
||||
static::$extensions['feed'][] = $feedName;
|
||||
|
|
Reference in a new issue