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

Commit

Permalink
Merge branch 'feature/RFCi18n-feed-dependencies' of https://github.co…
Browse files Browse the repository at this point in the history
…m/Maks3w/zf2 into hotfix/feed-i18n

Conflicts:
	library/Zend/Feed/Reader/Entry/Rss.php
	library/Zend/Feed/Reader/Extension/Atom/Entry.php
	library/Zend/Feed/Reader/Extension/Atom/Feed.php
	library/Zend/Feed/Reader/Extension/DublinCore/Entry.php
	library/Zend/Feed/Reader/Extension/DublinCore/Feed.php
	library/Zend/Feed/Reader/Extension/Syndication/Feed.php
	library/Zend/Feed/Reader/Feed/Atom.php
	library/Zend/Feed/Reader/Feed/Atom/Source.php
	library/Zend/Feed/Reader/Feed/Rss.php
	library/Zend/Feed/Writer/AbstractFeed.php
	library/Zend/Feed/Writer/Deleted.php
	library/Zend/Feed/Writer/Entry.php
	library/Zend/Feed/Writer/Feed.php
	library/Zend/Feed/Writer/Renderer/Entry/Atom.php
	library/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php
	library/Zend/Feed/Writer/Renderer/Entry/AtomDeleted.php
	library/Zend/Feed/Writer/Renderer/Entry/Rss.php
	library/Zend/Feed/Writer/Renderer/Feed/AbstractAtom.php
	library/Zend/Feed/Writer/Renderer/Feed/Atom/AbstractAtom.php
	library/Zend/Feed/Writer/Renderer/Feed/Rss.php
  • Loading branch information
Show file tree
Hide file tree
Showing 41 changed files with 383 additions and 1,000 deletions.
23 changes: 12 additions & 11 deletions src/PubSubHubbub/Model/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

namespace Zend\Feed\PubSubHubbub\Model;

use Zend\Date;
use DateInterval;
use DateTime;
use Zend\Feed\PubSubHubbub;

/**
Expand All @@ -34,9 +35,9 @@
class Subscription extends AbstractModel implements SubscriptionPersistenceInterface
{
/**
* Common Date\Date object to assist with unit testing
* Common DateTime object to assist with unit testing
*
* @var Date\Date
* @var DateTime
*/
protected $now;

Expand All @@ -61,8 +62,8 @@ public function setSubscription(array $data)
if (array_key_exists('lease_seconds', $data)
&& $data['lease_seconds']
) {
$data['expiration_time'] = $now->add($data['lease_seconds'], Date\Date::SECOND)
->get('yyyy-MM-dd HH:mm:ss');
$data['expiration_time'] = $now->add(new DateInterval('PT' . $data['lease_seconds'] . 'S'))
->format('Y-m-d H:i:s');
}
$this->_db->update(
$data,
Expand Down Expand Up @@ -134,25 +135,25 @@ public function deleteSubscription($key)
}

/**
* Get a new Date\Date or the one injected for testing
* Get a new DateTime or the one injected for testing
*
* @return Date\Date
* @return DateTime
*/
public function getNow()
{
if (null === $this->now) {
return new Date\Date;
return new DateTime();
}
return $this->now;
}

/**
* Set a Date\Date instance for assisting with unit testing
* Set a DateTime instance for assisting with unit testing
*
* @param Date\Date $now
* @param DateTime $now
* @return Subscription
*/
public function setNow(Date\Date $now)
public function setNow(DateTime $now)
{
$this->now = $now;
return $this;
Expand Down
11 changes: 6 additions & 5 deletions src/PubSubHubbub/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@

namespace Zend\Feed\PubSubHubbub;

use DateInterval;
use DateTime;
use Traversable;
use Zend\Stdlib\ArrayUtils;
use Zend\Date;
use Zend\Http\Request as HttpRequest;
use Zend\Uri;
use Zend\Version;
Expand Down Expand Up @@ -740,17 +741,17 @@ protected function _getRequestParameters($hubUrl, $mode)
}

// store subscription to storage
$now = new Date\Date;
$now = new DateTime();
$expires = null;
if (isset($params['hub.lease_seconds'])) {
$expires = $now->add($params['hub.lease_seconds'], Date\Date::SECOND)
->get('yyyy-MM-dd HH:mm:ss');
$expires = $now->add(new DateInterval('PT' . $params['hub.lease_seconds'] . 'S'))
->format('Y-m-d H:i:s');
}
$data = array(
'id' => $key,
'topic_url' => $params['hub.topic'],
'hub_url' => $hubUrl,
'created_time' => $now->get('yyyy-MM-dd HH:mm:ss'),
'created_time' => $now->format('Y-m-d H:i:s'),
'lease_seconds' => $expires,
'verify_token' => hash('sha256', $params['hub.verify_token']),
'secret' => null,
Expand Down
19 changes: 9 additions & 10 deletions src/Reader/Entry/Rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

namespace Zend\Feed\Reader\Entry;

use Zend\Feed\Reader;
use Zend\Date;
use Zend\Feed\Reader\Exception;
use DateTime;
use DOMElement;
use DOMXPath;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Exception;

/**
* @category Zend
Expand Down Expand Up @@ -219,17 +219,16 @@ public function getDateModified()
if ($dateModified) {
$dateModifiedParsed = strtotime($dateModified);
if ($dateModifiedParsed) {
$date = new Date\Date($dateModifiedParsed);
$date = new DateTime('@' . $dateModifiedParsed);
} else {
$dateStandards = array(Date\Date::RSS, Date\Date::RFC_822,
Date\Date::RFC_2822, Date\Date::DATES);
$date = new Date\Date;
$dateStandards = array(DateTime::RSS, DateTime::RFC822,
DateTime::RFC2822, null);
foreach ($dateStandards as $standard) {
try {
$date->set($dateModified, $standard);
$date = date_create_from_format($standard, $dateModified);
break;
} catch (Date\Exception\ExceptionInterface $e) {
if ($standard == Date\Date::DATES) {
} catch (\Exception $e) {
if ($standard == null) {
throw new Exception\RuntimeException(
'Could not load date due to unrecognised'
.' format (should follow RFC 822 or 2822):'
Expand Down
8 changes: 3 additions & 5 deletions src/Reader/Extension/Atom/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

namespace Zend\Feed\Reader\Extension\Atom;

use DateTime;
use DOMDocument;
use DOMElement;
use stdClass;
use Zend\Date;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Collection;
use Zend\Feed\Reader\Extension;
Expand Down Expand Up @@ -187,8 +187,7 @@ public function getDateCreated()
}

if ($dateCreated) {
$date = new Date\Date;
$date->set($dateCreated, Date\Date::ISO_8601);
$date = DateTime::createFromFormat(DateTime::ISO8601, $dateCreated);
}

$this->_data['datecreated'] = $date;
Expand Down Expand Up @@ -216,8 +215,7 @@ public function getDateModified()
}

if ($dateModified) {
$date = new Date\Date;
$date->set($dateModified, Date\Date::ISO_8601);
$date = DateTime::createFromFormat(DateTime::ISO8601, $dateModified);
}

$this->_data['datemodified'] = $date;
Expand Down
14 changes: 6 additions & 8 deletions src/Reader/Extension/Atom/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

namespace Zend\Feed\Reader\Extension\Atom;

use Zend\Date;
use DateTime;
use DOMElement;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Collection;
use Zend\Feed\Reader\Extension;
use Zend\Uri;
use DOMElement;

/**
* @category Zend
Expand Down Expand Up @@ -120,7 +120,7 @@ public function getCopyright()
/**
* Get the feed creation date
*
* @return Date\Date|null
* @return DateTime|null
*/
public function getDateCreated()
{
Expand All @@ -137,8 +137,7 @@ public function getDateCreated()
}

if ($dateCreated) {
$date = new Date\Date;
$date->set($dateCreated, Date\Date::ISO_8601);
$date = DateTime::createFromFormat(DateTime::ISO8601, $dateCreated);
}

$this->_data['datecreated'] = $date;
Expand All @@ -149,7 +148,7 @@ public function getDateCreated()
/**
* Get the feed modification date
*
* @return Date\Date|null
* @return DateTime|null
*/
public function getDateModified()
{
Expand All @@ -166,8 +165,7 @@ public function getDateModified()
}

if ($dateModified) {
$date = new Date\Date;
$date->set($dateModified, Date\Date::ISO_8601);
$date = DateTime::createFromFormat(DateTime::ISO8601, $dateModified);
}

$this->_data['datemodified'] = $date;
Expand Down
9 changes: 4 additions & 5 deletions src/Reader/Extension/DublinCore/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

namespace Zend\Feed\Reader\Extension\DublinCore;

use DateTime;
use DOMElement;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Collection;
use Zend\Feed\Reader\Extension;
use Zend\Date;
use DOMElement;

/**
* @category Zend
Expand Down Expand Up @@ -219,7 +219,7 @@ public function getTitle()
/**
*
*
* @return Date\Date|null
* @return DateTime|null
*/
public function getDate()
{
Expand All @@ -235,8 +235,7 @@ public function getDate()
}

if ($date) {
$d = new Date\Date;
$d->set($date, Date\Date::ISO_8601);
$d = DateTime::createFromFormat(DateTime::ISO8601, $date);
}

$this->_data['date'] = $d;
Expand Down
7 changes: 3 additions & 4 deletions src/Reader/Extension/DublinCore/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

namespace Zend\Feed\Reader\Extension\DublinCore;

use DateTime;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Collection;
use Zend\Feed\Reader\Extension;
use Zend\Date;

/**
* @category Zend
Expand Down Expand Up @@ -227,7 +227,7 @@ public function getTitle()
/**
*
*
* @return Date\Date|null
* @return DateTime|null
*/
public function getDate()
{
Expand All @@ -243,8 +243,7 @@ public function getDate()
}

if ($date) {
$d = new Date\Date;
$d->set($date, Date\Date::ISO_8601);
$d = DateTime::createFromFormat(DateTime::ISO8601, $date);
}

$this->_data['date'] = $d;
Expand Down
7 changes: 3 additions & 4 deletions src/Reader/Extension/Syndication/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

namespace Zend\Feed\Reader\Extension\Syndication;

use DateTime;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Extension;
use Zend\Date;

/**
* @category Zend
Expand Down Expand Up @@ -118,15 +118,14 @@ public function getUpdateFrequencyAsTicks()
/**
* Get update base
*
* @return Date\Date|null
* @return DateTime|null
*/
public function getUpdateBase()
{
$updateBase = $this->_getData('updateBase');
$date = null;
if ($updateBase) {
$date = new Date\Date;
$date->set($updateBase, Date\Date::W3C);
$date = DateTime::createFromFormat(DateTime::W3C, $updateBase);
}
return $date;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Reader/Feed/Atom.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@

namespace Zend\Feed\Reader\Feed;

use Zend\Feed\Reader;
use Zend\Date;
use DOMDocument;
use Zend\Feed\Reader;

/**
* @category Zend
Expand Down
5 changes: 2 additions & 3 deletions src/Reader/Feed/Atom/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@

namespace Zend\Feed\Reader\Feed\Atom;

use Zend\Feed\Reader;
use Zend\Feed\Reader\Feed;
use Zend\Date;
use DOMElement;
use DOMXPath;
use Zend\Feed\Reader;
use Zend\Feed\Reader\Feed;

/**
* @category Zend
Expand Down
Loading

0 comments on commit 3ac5190

Please sign in to comment.