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

Commit

Permalink
Merge branch 'develop' of https://github.com/zendframework/zf2 into d…
Browse files Browse the repository at this point in the history
…evelop
  • Loading branch information
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 83 deletions.
5 changes: 0 additions & 5 deletions src/AutoloaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader;
Expand All @@ -19,10 +18,6 @@
return;
}

/**
* @category Zend
* @package Zend_Loader
*/
abstract class AutoloaderFactory
{
const STANDARD_AUTOLOADER = 'Zend\Loader\StandardAutoloader';
Expand Down
4 changes: 0 additions & 4 deletions src/ClassMapAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader;
Expand All @@ -19,9 +18,6 @@
* Class-map autoloader
*
* Utilizes class-map files to lookup classfile locations.
*
* @category Zend
* @package Zend_Loader
*/
class ClassMapAutoloader implements SplAutoloader
{
Expand Down
6 changes: 0 additions & 6 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader\Exception;

require_once __DIR__ . '/ExceptionInterface.php';

/**
* @category Zend
* @package Zend_Loader
* @subpackage Exception
*/
class BadMethodCallException extends \BadMethodCallException implements
ExceptionInterface
{
Expand Down
6 changes: 0 additions & 6 deletions src/Exception/DomainException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader\Exception;

require_once __DIR__ . '/ExceptionInterface.php';

/**
* @category Zend
* @package Zend_Loader
* @subpackage Exception
*/
class DomainException extends \DomainException implements ExceptionInterface
{}
5 changes: 0 additions & 5 deletions src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader\Exception;

/**
* @category Zend
* @package Zend_Loader
*/
interface ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader\Exception;

require_once __DIR__ . '/ExceptionInterface.php';

/**
* @category Zend
* @package Zend_Loader
* @subpackage Exception
*/
class InvalidArgumentException extends \InvalidArgumentException implements
ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Exception/InvalidPathException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader\Exception;

require_once __DIR__ . '/ExceptionInterface.php';

/**
* @category Zend
* @package Zend_Loader
* @subpackage Exception
*/
class InvalidPathException extends \Exception implements ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Exception/MissingResourceNamespaceException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader\Exception;

require_once __DIR__ . '/ExceptionInterface.php';

/**
* @category Zend
* @package Zend_Loader
* @subpackage Exception
*/
class MissingResourceNamespaceException extends \Exception implements
ExceptionInterface
{}
5 changes: 0 additions & 5 deletions src/Exception/PluginLoaderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader\Exception;
Expand All @@ -14,10 +13,6 @@

/**
* Plugin class loader exceptions
*
* @category Zend
* @package Zend_Loader
* @subpackage Exception
*/
class PluginLoaderException extends DomainException
{
Expand Down
6 changes: 0 additions & 6 deletions src/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader\Exception;

require_once __DIR__ . '/ExceptionInterface.php';

/**
* @category Zend
* @package Zend_Loader
* @subpackage Exception
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
{}
6 changes: 0 additions & 6 deletions src/Exception/SecurityException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader\Exception;

require_once __DIR__ . '/DomainException.php';

/**
* @category Zend
* @package Zend_Loader
* @subpackage Exception
*/
class SecurityException extends DomainException
{}
35 changes: 32 additions & 3 deletions src/ModuleAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader;
Expand Down Expand Up @@ -98,6 +97,29 @@ public function setOptions($options)
return $this;
}

/**
* Retrieves the class map for all loaded modules.
*
* @return array
*/
public function getModuleClassMap()
{
return $this->moduleClassMap;
}

/**
* Sets the class map used to speed up the module autoloading.
*
* @param array $classmap
* @return ModuleLoader
*/
public function setModuleClassMap(array $classmap)
{
$this->moduleClassMap = $classmap;

return $this;
}

/**
* Autoload a class
*
Expand All @@ -113,6 +135,11 @@ public function autoload($class)
return false;
}

if (isset($this->moduleClassMap[$class])) {
require_once $this->moduleClassMap[$class];
return $class;
}

$moduleName = substr($class, 0, -7);
if (isset($this->explicitPaths[$moduleName])) {
$classLoaded = $this->loadModuleFromDir($this->explicitPaths[$moduleName], $class);
Expand Down Expand Up @@ -295,7 +322,8 @@ public function unregister()
public function registerPaths($paths)
{
if (!is_array($paths) && !$paths instanceof Traversable) {
throw new \InvalidArgumentException(
require_once __DIR__ . '/Exception/InvalidArgumentException.php';
throw new Exception\InvalidArgumentException(
'Parameter to \\Zend\\Loader\\ModuleAutoloader\'s '
. 'registerPaths method must be an array or '
. 'implement the \\Traversable interface'
Expand Down Expand Up @@ -324,7 +352,8 @@ public function registerPaths($paths)
public function registerPath($path, $moduleName = false)
{
if (!is_string($path)) {
throw new \InvalidArgumentException(sprintf(
require_once __DIR__ . '/Exception/InvalidArgumentException.php';
throw new Exception\InvalidArgumentException(sprintf(
'Invalid path provided; must be a string, received %s',
gettype($path)
));
Expand Down
4 changes: 0 additions & 4 deletions src/PluginClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader;
Expand All @@ -16,9 +15,6 @@

/**
* Plugin class locator interface
*
* @category Zend
* @package Zend_Loader
*/
class PluginClassLoader implements PluginClassLocator
{
Expand Down
4 changes: 0 additions & 4 deletions src/PluginClassLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader;
Expand All @@ -14,9 +13,6 @@

/**
* Plugin class locator interface
*
* @category Zend
* @package Zend_Loader
*/
interface PluginClassLocator extends ShortNameLocator, \IteratorAggregate
{
Expand Down
4 changes: 0 additions & 4 deletions src/ShortNameLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader;

/**
* Short name locator interface
*
* @category Zend
* @package Zend_Loader
*/
interface ShortNameLocator
{
Expand Down
3 changes: 0 additions & 3 deletions src/SplAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader;
Expand All @@ -17,8 +16,6 @@
/**
* Defines an interface for classes that may register with the spl_autoload
* registry
*
* @package Zend_Loader
*/
interface SplAutoloader
{
Expand Down
3 changes: 0 additions & 3 deletions src/StandardAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace Zend\Loader;
Expand All @@ -19,8 +18,6 @@
* Allows autoloading both namespaced and vendor-prefixed classes. Class
* lookups are performed on the filesystem. If a class file for the referenced
* class is not found, a PHP warning will be raised by include().
*
* @package Zend_Loader
*/
class StandardAutoloader implements SplAutoloader
{
Expand Down
14 changes: 13 additions & 1 deletion test/ModuleAutoloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,19 @@ public function testCanLoadModulesFromExplicitLocation()
$this->assertTrue(class_exists('PharModuleExplicit\Module'));
}

public function testCanLoadModulesFromClassMap()
{
$loader = new ModuleAutoloader();
$loader->setModuleClassMap(array(
'BarModule\Module' => __DIR__ . '/_files/BarModule/Module.php',
'PharModuleMap\Module' => __DIR__ . '/_files/PharModuleMap.phar',
));
$loader->register();

$this->assertTrue(class_exists('BarModule\Module'));
$this->assertTrue(class_exists('PharModuleMap\Module'));
}

public function testCanLoadModulesFromNamespace()
{
$loader = new ModuleAutoloader(array(
Expand All @@ -208,5 +221,4 @@ public function testCanLoadModulesFromNamespace()
$this->assertTrue(class_exists('FooModule\SubModule\Module'));
$this->assertTrue(class_exists('FooModule\Module'));
}

}
15 changes: 15 additions & 0 deletions test/_files/BarModule/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Loader
*/

namespace BarModule;

class Module
{
}
Binary file added test/_files/PharModuleMap.phar
Binary file not shown.
Loading

0 comments on commit 603dabb

Please sign in to comment.