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

Commit

Permalink
Merge branch 'master' of git://github.com/zendframework/zf2
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasweidner committed Jun 26, 2011
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 98 deletions.
4 changes: 2 additions & 2 deletions src/Exception.php
Expand Up @@ -28,12 +28,12 @@
*
* Class to represent exceptions that occur during Feed operations.
*
* @uses \Zend\Exception
* @uses \Exception
* @category Zend
* @package Zend_Feed
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Exception extends \Zend\Exception
class Exception extends \Exception
{}

4 changes: 2 additions & 2 deletions src/PubSubHubbub/Exception.php
Expand Up @@ -24,11 +24,11 @@
namespace Zend\Feed\PubSubHubbub;

/**
* @uses \Zend\Exception
* @uses \Exception
* @category Zend
* @package Zend_Feed_Pubsubhubbub
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Exception extends \Zend\Exception
class Exception extends \Exception
{}
8 changes: 4 additions & 4 deletions src/Reader/Exception.php
Expand Up @@ -19,20 +19,20 @@
*/

/**
* @namespace
*/
* @namespace
*/
namespace Zend\Feed\Reader;

/**
* Feed exceptions
*
* Class to represent exceptions that occur during Feed operations.
*
* @uses \Zend\Exception
* @uses \Exception
* @category Zend
* @package Zend_Feed
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Exception extends \Zend\Exception
class Exception extends \Exception
{}
17 changes: 12 additions & 5 deletions src/Reader/Feed/AbstractFeed.php
Expand Up @@ -19,10 +19,12 @@
*/

/**
* @namespace
*/
* @namespace
*/
namespace Zend\Feed\Reader\Feed;
use Zend\Feed\Reader;

use Zend\Feed\Reader,
Zend\Feed\Reader\Exception;

/**
* @uses \Zend\Feed\Exception
Expand Down Expand Up @@ -291,13 +293,18 @@ public function getExtension($name)

protected function _loadExtensions()
{
$all = Reader\Reader::getExtensions();
$all = Reader\Reader::getExtensions();
$feed = $all['feed'];
foreach ($feed as $extension) {
if (in_array($extension, $all['core'])) {
continue;
}
$className = Reader\Reader::getPluginLoader()->getClassName($extension);
if (!$className = Reader\Reader::getPluginLoader()->getClassName($extension)) {
continue;
}
if (!class_exists($className)) {
throw new Exception(sprintf('Unable to load extension "%s"; cannot find class', $extension));
}
$this->_extensions[$extension] = new $className(
$this->getDomDocument(), $this->_data['type'], $this->_xpath
);
Expand Down
6 changes: 3 additions & 3 deletions src/Reader/Feed/Rss.php
Expand Up @@ -52,10 +52,10 @@ public function __construct(\DomDocument $dom, $type = null)
{
parent::__construct($dom, $type);

$dublinCoreClass = Reader\Reader::getPluginLoader()->getClassName('DublinCore\\Feed');
$this->_extensions['DublinCore\\Feed'] = new $dublinCoreClass($dom, $this->_data['type'], $this->_xpath);
$dublinCoreClass = Reader\Reader::getPluginLoader()->getClassName('DublinCore\Feed');
$this->_extensions['DublinCore\Feed'] = new $dublinCoreClass($dom, $this->_data['type'], $this->_xpath);
$atomClass = Reader\Reader::getPluginLoader()->getClassName('Atom\\Feed');
$this->_extensions['Atom\\Feed'] = new $atomClass($dom, $this->_data['type'], $this->_xpath);
$this->_extensions['Atom\Feed'] = new $atomClass($dom, $this->_data['type'], $this->_xpath);

if ($this->getType() !== Reader\Reader::TYPE_RSS_10 && $this->getType() !== Reader\Reader::TYPE_RSS_090) {
$xpathPrefix = '/rss/channel';
Expand Down
60 changes: 25 additions & 35 deletions src/Reader/Reader.php
Expand Up @@ -22,17 +22,11 @@
* @namespace
*/
namespace Zend\Feed\Reader;
use Zend\HTTP;
use Zend\Loader;

use Zend\Http,
Zend\Loader;

/**
* @uses \Zend\Feed\Feed
* @uses \Zend\Feed\Exception
* @uses \Zend\Feed\Reader\FeedSet
* @uses \Zend\Feed\Reader\Feed\Atom\Atom
* @uses \Zend\Feed\Reader\Feed\RSS
* @uses \Zend\HTTP\Client
* @uses \Zend\Loader\PluginLoader
* @category Zend
* @package Zend_Feed_Reader
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down Expand Up @@ -78,7 +72,7 @@ class Reader
/**
* HTTP client object to use for retrieving feeds
*
* @var \Zend\HTTP\Client
* @var \Zend\Http\Client
*/
protected static $_httpClient = null;

Expand Down Expand Up @@ -140,24 +134,24 @@ public static function setCache(\Zend\Cache\Core $cache)
*
* Sets the HTTP client object to use for retrieving the feeds.
*
* @param \Zend\HTTP\Client $httpClient
* @param \Zend\Http\Client $httpClient
* @return void
*/
public static function setHttpClient(HTTP\Client $httpClient)
public static function setHttpClient(Http\Client $httpClient)
{
self::$_httpClient = $httpClient;
}


/**
* Gets the HTTP client object. If none is set, a new \Zend\HTTP\Client will be used.
* Gets the HTTP client object. If none is set, a new \Zend\Http\Client will be used.
*
* @return \Zend\HTTP\Client
* @return \Zend\Http\Client
*/
public static function getHttpClient()
{
if (!self::$_httpClient instanceof HTTP\Client) {
self::$_httpClient = new HTTP\Client();
if (!self::$_httpClient instanceof Http\Client) {
self::$_httpClient = new Http\Client();
}

return self::$_httpClient;
Expand Down Expand Up @@ -481,23 +475,23 @@ public static function detectType($feed, $specOnly = false)
/**
* Set plugin loader for use with Extensions
*
* @param \Zend\Loader\ShortNameLocater $loader
* @param \Zend\Loader\ShortNameLocator $loader
*/
public static function setPluginLoader(Loader\ShortNameLocater $loader)
public static function setPluginLoader(Loader\ShortNameLocator $loader)
{
self::$_pluginLoader = $loader;
}

/**
* Get plugin loader for use with Extensions
*
* @return \Zend\Loader\PluginLoader $loader
* @return \Zend\Loader\PrefixPathLoader $loader
*/
public static function getPluginLoader()
{
if (!isset(self::$_pluginLoader)) {
self::setPluginLoader(new Loader\PluginLoader(array(
'Zend\\Feed\\Reader\\Extension\\' => 'Zend/Feed/Reader/Extension/',
self::setPluginLoader(new Loader\PrefixPathLoader(array(
'Zend\Feed\Reader\Extension\\' => 'Zend/Feed/Reader/Extension/',
)));
}
return self::$_pluginLoader;
Expand Down Expand Up @@ -553,27 +547,23 @@ public static function registerExtension($name)
{
$feedName = $name . '\Feed';
$entryName = $name . '\Entry';
$loader = self::getPluginLoader();
if (self::isRegistered($name)) {
if (self::getPluginLoader()->isLoaded($feedName) ||
self::getPluginLoader()->isLoaded($entryName)) {
if ($loader->isLoaded($feedName) || $loader->isLoaded($entryName)) {
return;
}
}
try {
self::getPluginLoader()->load($feedName);
$loader->load($feedName);
$loader->load($entryName);
if (!$loader->isLoaded($feedName) && !$loader->isLoaded($entryName)) {
throw new \Zend\Feed\Exception('Could not load extension: ' . $name
. ' using Plugin Loader. Check prefix paths are configured and extension exists.');
}
if ($loader->isLoaded($feedName)) {
self::$_extensions['feed'][] = $feedName;
} catch (Loader\PluginLoaderException $e) {
}
try {
self::getPluginLoader()->load($entryName);
if ($loader->isLoaded($entryName)) {
self::$_extensions['entry'][] = $entryName;
} catch (Loader\PluginLoaderException $e) {
}
if (!self::getPluginLoader()->isLoaded($feedName)
&& !self::getPluginLoader()->isLoaded($entryName)
) {
throw new \Zend\Feed\Exception('Could not load extension: ' . $name
. 'using Plugin Loader. Check prefix paths are configured and extension exists.');
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/Writer/AbstractFeed.php
Expand Up @@ -22,9 +22,10 @@
* @namespace
*/
namespace Zend\Feed\Writer;
use Zend\Uri;
use Zend\Date;
use Zend\Validator;

use Zend\Uri,
Zend\Date,
Zend\Validator;

/**
* @uses \Zend\Date\Date
Expand Down Expand Up @@ -785,7 +786,9 @@ protected function _loadExtensions()
$all = Writer::getExtensions();
$exts = $all['feed'];
foreach ($exts as $ext) {
$className = Writer::getPluginLoader()->getClassName($ext);
if (!$className = Writer::getPluginLoader()->getClassName($ext)) {
throw new Exception(sprintf('Unable to load extension "%s"; could not resolve to class', $ext));
}
$this->_extensions[$ext] = new $className();
$this->_extensions[$ext]->setEncoding($this->getEncoding());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Writer/Exception.php
Expand Up @@ -28,11 +28,11 @@
*
* Class to represent exceptions that occur during Feed operations.
*
* @uses \Zend\Exception
* @uses \Exception
* @category Zend
* @package Zend_Feed
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Exception extends \Zend\Exception
class Exception extends \Exception
{}
2 changes: 1 addition & 1 deletion src/Writer/Exception/InvalidMethodException.php
Expand Up @@ -38,5 +38,5 @@
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InvalidMethodException extends \Zend\Exception
class InvalidMethodException extends \Exception
{}
4 changes: 2 additions & 2 deletions src/Writer/InvalidMethodException.php
Expand Up @@ -29,11 +29,11 @@
*
* Class to represent exceptions that occur during Feed operations.
*
* @uses \Zend\Exception
* @uses \Exception
* @category Zend
* @package Zend_Feed
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class InvalidMethodException extends \Zend\Exception
class InvalidMethodException extends \Exception
{}

0 comments on commit c54156c

Please sign in to comment.