12 * obtain it through the world-wide-web, please send an email |
12 * obtain it through the world-wide-web, please send an email |
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Loader |
16 * @package Zend_Loader |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 */ |
19 */ |
20 |
20 |
21 require_once dirname(__FILE__) . '/SplAutoloader.php'; |
21 require_once dirname(__FILE__) . '/SplAutoloader.php'; |
22 |
22 |
23 if (class_exists('Zend_Loader_AutoloaderFactory')) return; |
23 if (class_exists('Zend_Loader_AutoloaderFactory')) return; |
24 |
24 |
25 /** |
25 /** |
26 * @package Zend_Loader |
26 * @package Zend_Loader |
27 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
27 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
28 * @license http://framework.zend.com/license/new-bsd New BSD License |
28 * @license http://framework.zend.com/license/new-bsd New BSD License |
29 */ |
29 */ |
30 abstract class Zend_Loader_AutoloaderFactory |
30 abstract class Zend_Loader_AutoloaderFactory |
31 { |
31 { |
32 const STANDARD_AUTOLOADER = 'Zend_Loader_StandardAutoloader'; |
32 const STANDARD_AUTOLOADER = 'Zend_Loader_StandardAutoloader'; |
|
33 const CLASS_MAP_AUTOLOADER = 'Zend_Loader_ClassMapAutoloader'; |
33 |
34 |
34 /** |
35 /** |
35 * @var array All autoloaders registered using the factory |
36 * @var array All autoloaders registered using the factory |
36 */ |
37 */ |
37 protected static $loaders = array(); |
38 protected static $loaders = array(); |
87 ); |
88 ); |
88 } |
89 } |
89 |
90 |
90 foreach ($options as $class => $options) { |
91 foreach ($options as $class => $options) { |
91 if (!isset(self::$loaders[$class])) { |
92 if (!isset(self::$loaders[$class])) { |
|
93 // Check class map autoloader |
|
94 if ($class == self::CLASS_MAP_AUTOLOADER) { |
|
95 if (!class_exists(self::CLASS_MAP_AUTOLOADER)) { |
|
96 // Extract the filename from the classname |
|
97 $classMapLoader = substr( |
|
98 strrchr(self::CLASS_MAP_AUTOLOADER, '_'), 1 |
|
99 ); |
|
100 |
|
101 require_once dirname(__FILE__) . "/$classMapLoader.php"; |
|
102 } |
|
103 } |
|
104 |
|
105 // Autoload with standard autoloader |
92 $autoloader = self::getStandardAutoloader(); |
106 $autoloader = self::getStandardAutoloader(); |
93 if (!class_exists($class) && !$autoloader->autoload($class)) { |
107 if (!class_exists($class) && !$autoloader->autoload($class)) { |
94 require_once 'Exception/InvalidArgumentException.php'; |
108 require_once 'Exception/InvalidArgumentException.php'; |
95 throw new Zend_Loader_Exception_InvalidArgumentException(sprintf( |
109 throw new Zend_Loader_Exception_InvalidArgumentException(sprintf( |
96 'Autoloader class "%s" not loaded', |
110 'Autoloader class "%s" not loaded', |