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

Commit

Permalink
s/Locater/Locator/gs
Browse files Browse the repository at this point in the history
- Fixed all instances where class/interface names used "Locater" to "Locator",
  and attempted to ensure tests would run when possible (in some cases, tests
  were failing before)
  • Loading branch information
weierophinney committed Apr 14, 2011
11 parents 352e42b + fa459f5 + 3eff137 + 3648ab6 + 4096125 + 0037391 + 9bdfcd9 + 6cd1498 + ecac99d + 199ed75 + b8507f7 commit decb6ae
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 90 deletions.
2 changes: 1 addition & 1 deletion src/Exception.php
Expand Up @@ -34,6 +34,6 @@
* @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
{}

6 changes: 3 additions & 3 deletions src/Reader/Exception.php
Expand Up @@ -19,8 +19,8 @@
*/

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

/**
Expand All @@ -34,5 +34,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 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
2 changes: 1 addition & 1 deletion src/Writer/Exception.php
Expand Up @@ -34,5 +34,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 Exception extends \Zend\Exception
class Exception extends \Exception
{}
73 changes: 37 additions & 36 deletions src/Writer/Writer.php
Expand Up @@ -22,7 +22,11 @@
* @namespace
*/
namespace Zend\Feed\Writer;
use Zend\Loader;

use Zend\Loader\ShortNameLocator,
Zend\Loader\PrefixPathLoader,
Zend\Loader\PrefixPathMapper,
Zend\Loader\Exception\PluginLoaderException;

/**
* @uses \Zend\Feed\Exception
Expand Down Expand Up @@ -64,7 +68,7 @@ class Writer
/**
* PluginLoader instance used by component
*
* @var \Zend\Loader\ShortNameLocater
* @var \Zend\Loader\ShortNameLocator
*/
protected static $_pluginLoader = null;

Expand Down Expand Up @@ -92,22 +96,22 @@ class Writer
/**
* Set plugin loader for use with Extensions
*
* @param \Zend\Loader\ShortNameLocater
* @param \Zend\Loader\ShortNameLocator
*/
public static function setPluginLoader(ShortNameLocater $loader)
public static function setPluginLoader(ShortNameLocator $loader)
{
self::$_pluginLoader = $loader;
}

/**
* Get plugin loader for use with Extensions
*
* @return \Zend\Loader\ShortNameLocater
* @return \Zend\Loader\ShortNameLocator
*/
public static function getPluginLoader()
{
if (!isset(self::$_pluginLoader)) {
self::$_pluginLoader = new Loader\PluginLoader(array(
self::$_pluginLoader = new PrefixPathLoader(array(
'Zend\\Feed\\Writer\\Extension\\' => 'Zend/Feed/Writer/Extension/',
));
}
Expand All @@ -124,7 +128,7 @@ public static function getPluginLoader()
public static function addPrefixPath($prefix, $path)
{
$pluginLoader = self::getPluginLoader();
if (!$pluginLoader instanceof Loader\PrefixPathMapper) {
if (!$pluginLoader instanceof PrefixPathMapper) {
return;
}
$prefix = rtrim($prefix, '\\');
Expand All @@ -141,7 +145,7 @@ public static function addPrefixPath($prefix, $path)
public static function addPrefixPaths(array $spec)
{
$pluginLoader = self::getPluginLoader();
if (!$pluginLoader instanceof Loader\PrefixPathMapper) {
if (!$pluginLoader instanceof PrefixPathMapper) {
return;
}
if (isset($spec['prefix']) && isset($spec['path'])) {
Expand All @@ -163,46 +167,43 @@ public static function addPrefixPaths(array $spec)
*/
public static function registerExtension($name)
{
$feedName = $name . '\\Feed';
$entryName = $name . '\\Entry';
$feedRendererName = $name . '\\Renderer\\Feed';
$entryRendererName = $name . '\\Renderer\\Entry';
$feedName = $name . '\Feed';
$entryName = $name . '\Entry';
$feedRendererName = $name . '\Renderer\Feed';
$entryRendererName = $name . '\Renderer\Entry';
$loader = self::getPluginLoader();
if (self::isRegistered($name)) {
if (self::getPluginLoader()->isLoaded($feedName)
|| self::getPluginLoader()->isLoaded($entryName)
|| self::getPluginLoader()->isLoaded($feedRendererName)
|| self::getPluginLoader()->isLoaded($entryRendererName)
if ($loader->isLoaded($feedName)
|| $loader->isLoaded($entryName)
|| $loader->isLoaded($feedRendererName)
|| $loader->isLoaded($entryRendererName)
) {
return;
}
}
try {
self::getPluginLoader()->load($feedName);
$loader->load($feedName);
$loader->load($entryName);
$loader->load($feedRendererName);
$loader->load($entryRendererName);
if (!$loader->isLoaded($feedName)
&& !$loader->isLoaded($entryName)
&& !$loader->isLoaded($feedRendererName)
&& !$loader->isLoaded($entryRendererName)
) {
throw new 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) {
}
try {
self::getPluginLoader()->load($feedRendererName);
if ($loader->isLoaded($feedRendererName)) {
self::$_extensions['feedRenderer'][] = $feedRendererName;
} catch (Loader\PluginLoaderException $e) {
}
try {
self::getPluginLoader()->load($entryRendererName);
if ($loader->isLoaded($entryRendererName)) {
self::$_extensions['entryRenderer'][] = $entryRendererName;
} catch (Loader\PluginLoaderException $e) {
}
if (!self::getPluginLoader()->isLoaded($feedName)
&& !self::getPluginLoader()->isLoaded($entryName)
&& !self::getPluginLoader()->isLoaded($feedRendererName)
&& !self::getPluginLoader()->isLoaded($entryRendererName)
) {
throw new Exception('Could not load extension: ' . $name
. 'using Plugin Loader. Check prefix paths are configured and extension exists.');
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/Reader/_files/My/Extension/JungleBooks/Entry.php
Expand Up @@ -22,7 +22,7 @@
/**
* @namespace
*/
namespace My\FeedReader\Extension\JungleBooks;
namespace My\Extension\JungleBooks;
use Zend\Feed\Reader\Extension;

/**
Expand Down
2 changes: 1 addition & 1 deletion test/Reader/_files/My/Extension/JungleBooks/Feed.php
Expand Up @@ -22,7 +22,7 @@
/**
* @namespace
*/
namespace My\FeedReader\Extension\JungleBooks;
namespace My\Extension\JungleBooks;
use Zend\Feed\Reader\Extension;

/**
Expand Down

0 comments on commit decb6ae

Please sign in to comment.