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://git.zendframework.com/zf into mikaelkael
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelkael committed Jul 7, 2010
4 parents 7c40ff9 + 024b855 + f6850f1 + 995dd45 commit ca06bae
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 76 deletions.
2 changes: 1 addition & 1 deletion src/AutoloaderInterface.php → src/Autoloadable.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface AutoloaderInterface
interface Autoloadable
{
public function autoload($class);
}
2 changes: 1 addition & 1 deletion src/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public static function autoload($class)
$self = self::getInstance();

foreach ($self->getClassAutoloaders($class) as $autoloader) {
if ($autoloader instanceof AutoloaderInterface) {
if ($autoloader instanceof Autoloadable) {
if ($autoloader->autoload($class)) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ClassNotFoundException.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
namespace Zend\Loader;

require_once __DIR__ . '/../Exception.php';
require_once __DIR__ . '/Exception.php';

class ClassNotFoundException
Expand Down
2 changes: 0 additions & 2 deletions src/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
namespace Zend\Loader;

require_once __DIR__ . '/Exception.php';

class InvalidArgumentException
extends \InvalidArgumentException
implements Exception
Expand Down
32 changes: 15 additions & 17 deletions src/PluginLoader/PluginLoader.php → src/PluginLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*
* @category Zend
* @package Zend_Loader
* @subpackage PluginLoader
* @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$
Expand All @@ -23,22 +22,21 @@
/**
* @namespace
*/
namespace Zend\Loader\PluginLoader;
namespace Zend\Loader;

/**
* Generic plugin class loader
*
* @uses ReflectionClass
* @uses \Zend\Loader
* @uses \Zend\Loader\PluginLoader\Exception
* @uses \Zend\Loader\PluginLoader\PluginLoaderInterface
* @uses \Zend\Loader\PluginLoaderException
* @uses \Zend\Loader\PrefixPathMapper
* @category Zend
* @package Zend_Loader
* @subpackage PluginLoader
* @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 PluginLoader implements PluginLoaderInterface
class PluginLoader implements PrefixPathMapper
{
/**
* Class map cache file
Expand Down Expand Up @@ -156,12 +154,12 @@ protected function _formatPrefix($prefix, $namespaced = true)
* @param string $prefix
* @param string $path
* @param bool $namespaced Whether the paths are namespaced or prefixed; namespaced by default
* @return \Zend\Loader\PluginLoader\PluginLoader
* @return \Zend\Loader\PluginLoader
*/
public function addPrefixPath($prefix, $path, $namespaced = true)
{
if (!is_string($prefix) || !is_string($path)) {
throw new Exception('Zend\\Loader\\PluginLoader::addPrefixPath() method only takes strings for prefix and path.');
throw new PluginLoaderException('Zend\\Loader\\PluginLoader::addPrefixPath() method only takes strings for prefix and path.');
}

$prefix = $this->_formatPrefix($prefix, $namespaced);
Expand Down Expand Up @@ -253,7 +251,7 @@ public function clearPaths($prefix = null)
*
* @param string $prefix
* @param string $path OPTIONAL
* @return \Zend\Loader\PluginLoader\PluginLoader
* @return \Zend\Loader\PluginLoader
*/
public function removePrefixPath($prefix, $path = null)
{
Expand All @@ -265,13 +263,13 @@ public function removePrefixPath($prefix, $path = null)
}

if (!isset($registry[$prefix])) {
throw new Exception('Prefix ' . $prefix . ' was not found in the PluginLoader.');
throw new PluginLoaderException('Prefix ' . $prefix . ' was not found in the PluginLoader.');
}

if ($path != null) {
$pos = array_search($path, $registry[$prefix]);
if (in_array($pos, array(null, false))) {
throw new Exception('Prefix ' . $prefix . ' / Path ' . $path . ' was not found in the PluginLoader.');
throw new PluginLoaderException('Prefix ' . $prefix . ' / Path ' . $path . ' was not found in the PluginLoader.');
}
unset($registry[$prefix][$pos]);
} else {
Expand All @@ -296,7 +294,7 @@ protected function _formatName($name)
* Whether or not a Plugin by a specific name is loaded
*
* @param string $name
* @return \Zend\Loader\PluginLoader\PluginLoader
* @return \Zend\Loader\PluginLoader
*/
public function isLoaded($name)
{
Expand Down Expand Up @@ -421,7 +419,7 @@ public function load($name, $throwExceptions = true)
foreach ($registry as $prefix => $paths) {
$message .= "\n$prefix: " . implode(PATH_SEPARATOR, $paths);
}
throw new Exception($message);
throw new PluginLoaderException($message);
}

if ($this->_useStaticRegistry) {
Expand All @@ -440,7 +438,7 @@ public function load($name, $throwExceptions = true)
*
* @param string $file
* @return void
* @throws \Zend\Loader\PluginLoader\Exception if file is not writeable or path does not exist
* @throws \Zend\Loader\PluginLoaderException if file is not writeable or path does not exist
*/
public static function setIncludeFileCache($file)
{
Expand All @@ -450,13 +448,13 @@ public static function setIncludeFileCache($file)
}

if (!file_exists($file) && !file_exists(dirname($file))) {
throw new Exception('Specified file does not exist and/or directory does not exist (' . $file . ')');
throw new PluginLoaderException('Specified file does not exist and/or directory does not exist (' . $file . ')');
}
if (file_exists($file) && !is_writable($file)) {
throw new Exception('Specified file is not writeable (' . $file . ')');
throw new PluginLoaderException('Specified file is not writeable (' . $file . ')');
}
if (!file_exists($file) && file_exists(dirname($file)) && !is_writable(dirname($file))) {
throw new Exception('Specified file is not writeable (' . $file . ')');
throw new PluginLoaderException('Specified file is not writeable (' . $file . ')');
}

self::$_includeFileCache = $file;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*
* @category Zend
* @package Zend_Loader
* @subpackage PluginLoader
* @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$
Expand All @@ -23,18 +22,17 @@
/**
* @namespace
*/
namespace Zend\Loader\PluginLoader;
namespace Zend\Loader;

/**
* Plugin class loader exceptions
*
* @uses \Zend\Loader\Exception
* @category Zend
* @package Zend_Loader
* @subpackage PluginLoader
* @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 Exception extends \DomainException implements \Zend\Loader\Exception
class PluginLoaderException extends \DomainException implements Exception
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*
* @category Zend
* @package Zend_Loader
* @subpackage PluginLoader
* @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$
Expand All @@ -23,25 +22,24 @@
/**
* @namespace
*/
namespace Zend\Loader\PluginLoader;
namespace Zend\Loader;

/**
* Plugin class loader interface
*
* @category Zend
* @package Zend_Loader
* @subpackage PluginLoader
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface PluginLoaderInterface
interface PrefixPathMapper extends ShortNameLocater
{
/**
* Add prefixed paths to the registry of paths
*
* @param string $prefix
* @param string $path
* @return \Zend\Loader\PluginLoader\PluginLoaderInterface
* @return \Zend\Loader\PrefixPathMapper
*/
public function addPrefixPath($prefix, $path);

Expand All @@ -50,31 +48,7 @@ public function addPrefixPath($prefix, $path);
*
* @param string $prefix
* @param string $path OPTIONAL
* @return \Zend\Loader\PluginLoader\PluginLoaderInterface
* @return \Zend\Loader\PrefixPathMapper
*/
public function removePrefixPath($prefix, $path = null);

/**
* Whether or not a Helper by a specific name
*
* @param string $name
* @return \Zend\Loader\PluginLoader\PluginLoaderInterface
*/
public function isLoaded($name);

/**
* Return full class name for a named helper
*
* @param string $name
* @return string
*/
public function getClassName($name);

/**
* Load a helper via the name provided
*
* @param string $name
* @return string
*/
public function load($name);
}
4 changes: 2 additions & 2 deletions src/ResourceAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
*
* @uses Zend_Loader
* @uses Zend_Loader_Autoloader
* @uses Zend_Loader_Autoloader_Interface
* @uses Zend_Loader_Autoloadable
* @uses Zend_Loader_Exception
* @package Zend_Loader
* @subpackage Autoloader
* @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 ResourceAutoloader implements AutoloaderInterface
class ResourceAutoloader implements Autoloadable
{
/**
* @var string Base path to resource classes
Expand Down
6 changes: 1 addition & 5 deletions src/SecurityException.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?php
namespace Zend\Loader;

require_once __DIR__ . '/Exception.php';

class SecurityException
extends \Exception
implements Exception
class SecurityException extends \Exception implements Exception
{
}
60 changes: 60 additions & 0 deletions src/ShortNameLocater.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?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 [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Loader
* @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$
*/

/**
* @namespace
*/
namespace Zend\Loader;

/**
* Short name locater interface
*
* @category Zend
* @package Zend_Loader
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface ShortNameLocater
{
/**
* Whether or not a Helper by a specific name
*
* @param string $name
* @return bool
*/
public function isLoaded($name);

/**
* Return full class name for a named helper
*
* @param string $name
* @return string
*/
public function getClassName($name);

/**
* Load a helper via the name provided
*
* @param string $name
* @return string
*/
public function load($name);
}
2 changes: 1 addition & 1 deletion test/AutoloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ function testAutoload($class)
return $class;
}

class TestAutoloader implements \Zend\Loader\AutoloaderInterface
class TestAutoloader implements \Zend\Loader\Autoloadable
{
public function autoload($class)
{
Expand Down
Loading

0 comments on commit ca06bae

Please sign in to comment.