Permalink
Browse files

Merge branch 'master' of git://github.com/zendframework/zf2

  • Loading branch information...
sgehrig committed Apr 19, 2011
2 parents 010bbb8 + 450663d commit c93d1ef2fb77343d7891610a86c9c9e90c691446
Showing with 232 additions and 228 deletions.
  1. +2 −2 bin/classmap_generator.php
  2. +2 −2 bin/zfals.php
  3. +29 −1 library/Zend/Application/Application.php
  4. +18 −6 library/Zend/Barcode/Barcode.php
  5. +1 −1 library/Zend/Controller/Exception.php
  6. +0 −35 library/Zend/Exception.php
  7. +1 −1 library/Zend/Feed/Exception.php
  8. +3 −3 library/Zend/Feed/Reader/Exception.php
  9. +12 −5 library/Zend/Feed/Reader/Feed/AbstractFeed.php
  10. +3 −3 library/Zend/Feed/Reader/Feed/Rss.php
  11. +25 −35 library/Zend/Feed/Reader/Reader.php
  12. +7 −4 library/Zend/Feed/Writer/AbstractFeed.php
  13. +1 −1 library/Zend/Feed/Writer/Exception.php
  14. +37 −36 library/Zend/Feed/Writer/Writer.php
  15. +2 −2 library/Zend/File/{ClassFileLocater.php → ClassFileLocator.php}
  16. +4 −4 library/Zend/File/Transfer/Adapter/AbstractAdapter.php
  17. +3 −3 library/Zend/Loader/Broker.php
  18. +6 −6 library/Zend/Loader/PluginBroker.php
  19. +3 −3 library/Zend/Loader/PluginClassLoader.php
  20. +3 −3 library/Zend/Loader/{PluginClassLocater.php → PluginClassLocator.php}
  21. +1 −1 library/Zend/Loader/PrefixPathLoader.php
  22. +1 −1 library/Zend/Loader/PrefixPathMapper.php
  23. +2 −2 library/Zend/Loader/{ShortNameLocater.php → ShortNameLocator.php}
  24. +4 −3 library/Zend/Serializer/Adapter/PythonPickle.php
  25. +1 −1 library/Zend/Tag/Cloud/Decorator/HtmlCloud.php
  26. +1 −1 library/Zend/Tag/Cloud/Decorator/HtmlTag.php
  27. +1 −1 library/Zend/Text/MultiByte.php
  28. +4 −8 library/Zend/Text/Table/Table.php
  29. +1 −1 library/Zend/View/Exception.php
  30. +5 −5 library/Zend/View/Helper/Navigation.php
  31. +2 −2 library/Zend/View/Helper/Navigation/Breadcrumbs.php
  32. +2 −2 library/Zend/View/Helper/Navigation/Menu.php
  33. +2 −2 library/Zend/View/Helper/Navigation/Sitemap.php
  34. +1 −1 library/Zend/View/Helper/Partial.php
  35. +10 −10 tests/Zend/Barcode/FactoryTest.php
  36. +1 −1 tests/Zend/Feed/Reader/_files/My/Extension/JungleBooks/Entry.php
  37. +1 −1 tests/Zend/Feed/Reader/_files/My/Extension/JungleBooks/Feed.php
  38. +19 −18 tests/Zend/File/{ClassFileLocater.php → ClassFileLocatorTest.php}
  39. +1 −1 tests/Zend/File/TestAsset/{LocaterShouldFindThis.php → LocatorShouldFindThis.php}
  40. +2 −2 tests/Zend/File/Transfer/Adapter/AbstractTest.php
  41. +0 −2 tests/Zend/File/_files/locater-should-skip-this.php
  42. +2 −0 tests/Zend/File/_files/locator-should-skip-this.php
  43. 0 tests/Zend/File/_files/{locater-should-skip-this.xml → locator-should-skip-this.xml}
  44. +1 −1 tests/Zend/Loader/PluginBrokerTest.php
  45. +2 −2 tests/Zend/Tag/Cloud/CloudTest.php
  46. +1 −1 tests/Zend/View/Helper/Navigation/LinksTest.php
  47. +2 −2 tests/Zend/View/Helper/Navigation/_files/mvc/views/menu.phtml
@@ -114,8 +114,8 @@
echo "Creating class file map for library in '$path'..." . PHP_EOL;
}
-// Get the ClassFileLocater, and pass it the library path
-$l = new \Zend\File\ClassFileLocater($path);
+// Get the ClassFileLocator, and pass it the library path
+$l = new \Zend\File\ClassFileLocator($path);
// Iterate over each element in the path, and create a map of
// classname => filename, where the filename is relative to the library path
View
@@ -114,8 +114,8 @@
echo "Creating class file map for library in '$path'..." . PHP_EOL;
}
-// Get the ClassFileLocater, and pass it the library path
-$l = new \Zend\File\ClassFileLocater($path);
+// Get the ClassFileLocator, and pass it the library path
+$l = new \Zend\File\ClassFileLocator($path);
// Iterate over each element in the path, and create a map of
// classname => filename, where the filename is relative to the library path
@@ -174,6 +174,10 @@ public function setOptions(array $options)
$this->setAutoloaderNamespaces($options['autoloadernamespaces']);
}
+ if (!empty($option['autoloaderprefixes'])) {
+ $this->setAutoloaderPrefixes($options['autoloaderprefixes']);
+ }
+
if (!empty($options['autoloaderzfpath'])) {
$autoloader = $this->getAutoloader();
if (method_exists($autoloader, 'setZfPath')) {
@@ -314,7 +318,31 @@ public function setIncludePaths(array $paths)
public function setAutoloaderNamespaces(array $namespaces)
{
$autoloader = $this->getAutoloader();
- $autoloader->registerNamespaces($namespaces);
+
+ foreach ($namespaces as $namespace => $directory) {
+ $autoloader->registerNamespace($namespace, $directory);
+ }
+
+ $autoloader->register();
+
+ return $this;
+ }
+
+ /**
+ * Set autoloader prefixes
+ *
+ * @param array $prefixes
+ * @return \Zend\Application\Application
+ */
+ public function setAutoloaderPrefixes(array $prefixes)
+ {
+ $autoloader = $this->getAutoloader();
+
+ foreach ($prefixes as $prefix => $directory) {
+ $autoloader->registerPrefix($prefix, $directory);
+ }
+
+ $autoloader->register();
return $this;
}
@@ -22,8 +22,8 @@
* @namespace
*/
namespace Zend\Barcode;
-use Zend\Loader\PluginLoader,
- Zend\Loader\ShortNameLocater,
+use Zend\Loader\PrefixPathLoader,
+ Zend\Loader\ShortNameLocator,
Zend\Config\Config,
Zend,
Zend\Barcode\Exception\RendererCreationException,
@@ -64,12 +64,12 @@ class Barcode
/**
* Set plugin loader to use for validator or filter chain
*
- * @param \Zend\Loader\ShortNameLocater $loader
+ * @param \Zend\Loader\ShortNameLocator $loader
* @param string $type 'object', or 'renderer'
* @return \Zend\Form\Element
* @throws \Zend\Form\Exception on invalid type
*/
- public static function setPluginLoader(ShortNameLocater $loader, $type)
+ public static function setPluginLoader(ShortNameLocator $loader, $type)
{
$type = strtoupper($type);
switch ($type) {
@@ -89,7 +89,7 @@ public static function setPluginLoader(ShortNameLocater $loader, $type)
* 'decorator', 'filter', or 'validate' for $type.
*
* @param string $type
- * @return \Zend\Loader\ShortNameLocater
+ * @return \Zend\Loader\ShortNameLocator
* @throws \Zend\Loader\Exception on invalid type.
*/
public static function getPluginLoader($type)
@@ -101,7 +101,7 @@ public static function getPluginLoader($type)
$prefixSegment = ucfirst(strtolower($type));
$pathSegment = $prefixSegment;
if (!isset(self::$_loaders[$type])) {
- self::$_loaders[$type] = new PluginLoader(
+ self::$_loaders[$type] = new PrefixPathLoader(
array('Zend\\Barcode\\' . $prefixSegment . '\\' => 'Zend/Barcode/' . $pathSegment . '/')
);
}
@@ -230,6 +230,12 @@ public static function makeBarcode($barcode, $barcodeConfig = array())
$barcodeName = self::getPluginLoader(self::OBJECT)->load($barcode);
+ if (!class_exists($barcodeName)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Invalid Barcode "%s"; does not resolve to a valid class', $barcode
+ ));
+ }
+
/*
* Create an instance of the barcode class.
* Pass the config to the barcode class constructor.
@@ -296,6 +302,12 @@ public static function makeRenderer($renderer = 'image', $rendererConfig = array
$rendererName = self::getPluginLoader(self::RENDERER)->load($renderer);
+ if (!class_exists($rendererName)) {
+ throw new Exception\InvalidArgumentException(sprintf(
+ 'Invalid renderer "%s"; does not resolve to a valid class', $renderer
+ ));
+ }
+
/*
* Create an instance of the barcode class.
* Pass the config to the barcode class constructor.
@@ -30,5 +30,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
{}
View
@@ -1,35 +0,0 @@
-<?php
-/**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend
- * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
-
-/**
- * @namespace
- */
-namespace Zend;
-
-/**
- * @uses Exception
- * @category Zend
- * @package Zend
- * @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 \Exception
-{
-}
@@ -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
{}
@@ -19,8 +19,8 @@
*/
/**
-* @namespace
-*/
+ * @namespace
+ */
namespace Zend\Feed\Reader;
/**
@@ -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
{}
@@ -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
@@ -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
);
@@ -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';
@@ -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)
@@ -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;
@@ -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;
@@ -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;
@@ -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.');
}
}
Oops, something went wrong.

0 comments on commit c93d1ef

Please sign in to comment.