diff options
Diffstat (limited to 'libs/Zend/Loader/PluginLoader.php')
-rw-r--r-- | libs/Zend/Loader/PluginLoader.php | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/libs/Zend/Loader/PluginLoader.php b/libs/Zend/Loader/PluginLoader.php index 39ff94cfe5..f3f6170c67 100644 --- a/libs/Zend/Loader/PluginLoader.php +++ b/libs/Zend/Loader/PluginLoader.php @@ -15,16 +15,16 @@ * @category Zend * @package Zend_Loader * @subpackage PluginLoader - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: PluginLoader.php 18207 2009-09-17 22:29:50Z beberlei $ + * @version $Id: PluginLoader.php 21170 2010-02-23 19:50:16Z matthew $ */ /** Zend_Loader_PluginLoader_Interface */ -require_once 'Zend/Loader/PluginLoader/Interface.php'; +// require_once 'Zend/Loader/PluginLoader/Interface.php'; /** Zend_Loader */ -require_once 'Zend/Loader.php'; +// require_once 'Zend/Loader.php'; /** * Generic plugin class loader @@ -32,7 +32,7 @@ require_once 'Zend/Loader.php'; * @category Zend * @package Zend_Loader * @subpackage PluginLoader - * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface @@ -123,9 +123,15 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface */ protected function _formatPrefix($prefix) { - if($prefix == "") { - return $prefix; - } + if($prefix == "") { + return $prefix; + } + + $last = strlen($prefix) - 1; + if ($prefix{$last} == '\\') { + return $prefix; + } + return rtrim($prefix, '_') . '_'; } @@ -139,7 +145,7 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface public function addPrefixPath($prefix, $path) { if (!is_string($prefix) || !is_string($path)) { - require_once 'Zend/Loader/PluginLoader/Exception.php'; + // require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Zend_Loader_PluginLoader::addPrefixPath() method only takes strings for prefix and path.'); } @@ -244,14 +250,14 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface } if (!isset($registry[$prefix])) { - require_once 'Zend/Loader/PluginLoader/Exception.php'; + // require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Prefix ' . $prefix . ' was not found in the PluginLoader.'); } if ($path != null) { $pos = array_search($path, $registry[$prefix]); if ($pos === null) { - require_once 'Zend/Loader/PluginLoader/Exception.php'; + // require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Prefix ' . $prefix . ' / Path ' . $path . ' was not found in the PluginLoader.'); } unset($registry[$prefix][$pos]); @@ -298,7 +304,7 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface public function getClassName($name) { $name = $this->_formatName($name); - if ($this->_useStaticRegistry + if ($this->_useStaticRegistry && isset(self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]) ) { return self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name]; @@ -311,14 +317,14 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface /** * Get path to plugin class - * - * @param mixed $name + * + * @param mixed $name * @return string|false False if not found */ public function getClassPath($name) { $name = $this->_formatName($name); - if ($this->_useStaticRegistry + if ($this->_useStaticRegistry && !empty(self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name]) ) { return self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name]; @@ -345,9 +351,9 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface * Load a plugin via the name provided * * @param string $name - * @param bool $throwExceptions Whether or not to throw exceptions if the + * @param bool $throwExceptions Whether or not to throw exceptions if the * class is not resolved - * @return string|false Class name of loaded class; false if $throwExceptions + * @return string|false Class name of loaded class; false if $throwExceptions * if false and no class found * @throws Zend_Loader_Exception if class not found */ @@ -402,16 +408,14 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface foreach ($registry as $prefix => $paths) { $message .= "\n$prefix: " . implode(PATH_SEPARATOR, $paths); } - require_once 'Zend/Loader/PluginLoader/Exception.php'; + // require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception($message); } if ($this->_useStaticRegistry) { self::$_staticLoadedPlugins[$this->_useStaticRegistry][$name] = $className; - self::$_staticLoadedPluginPaths[$this->_useStaticRegistry][$name] = (isset($loadFile) ? $loadFile : ''); } else { $this->_loadedPlugins[$name] = $className; - $this->_loadedPluginPaths[$name] = (isset($loadFile) ? $loadFile : ''); } return $className; } @@ -419,10 +423,10 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface /** * Set path to class file cache * - * Specify a path to a file that will add include_once statements for each + * Specify a path to a file that will add include_once statements for each * plugin class loaded. This is an opt-in feature for performance purposes. - * - * @param string $file + * + * @param string $file * @return void * @throws Zend_Loader_PluginLoader_Exception if file is not writeable or path does not exist */ @@ -434,15 +438,15 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface } if (!file_exists($file) && !file_exists(dirname($file))) { - require_once 'Zend/Loader/PluginLoader/Exception.php'; + // require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Specified file does not exist and/or directory does not exist (' . $file . ')'); } if (file_exists($file) && !is_writable($file)) { - require_once 'Zend/Loader/PluginLoader/Exception.php'; + // require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')'); } if (!file_exists($file) && file_exists(dirname($file)) && !is_writable(dirname($file))) { - require_once 'Zend/Loader/PluginLoader/Exception.php'; + // require_once 'Zend/Loader/PluginLoader/Exception.php'; throw new Zend_Loader_PluginLoader_Exception('Specified file is not writeable (' . $file . ')'); } @@ -451,7 +455,7 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface /** * Retrieve class file cache path - * + * * @return string|null */ public static function getIncludeFileCache() @@ -461,8 +465,8 @@ class Zend_Loader_PluginLoader implements Zend_Loader_PluginLoader_Interface /** * Append an include_once statement to the class file cache - * - * @param string $incFile + * + * @param string $incFile * @return void */ protected static function _appendIncFile($incFile) |