| @@ -14,15 +14,8 @@ | ||
| 14 | 14 | */ |
| 15 | 15 | class CJT_Framework_Autoload_Loader { |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * | |
| 19 | - * | |
| 20 | - * @var mixed | |
| 21 | - */ | |
| 22 | - protected static $instances = array(); | |
| 23 | - | |
| 24 | - /** | |
| 25 | 18 | * put your comment there... |
| 26 | 19 | * |
| 27 | 20 | * @var mixed |
| 28 | 21 | */ |
| @@ -65,45 +58,18 @@ | ||
| 65 | 58 | * @param mixed $prefix |
| 66 | 59 | * @param mixed $path |
| 67 | 60 | */ |
| 68 | 61 | public static function autoLoad($prefix = null, $path = null) { |
| 62 | + // Hold all auto load instances. | |
| 63 | + static $instances = array(); | |
| 69 | 64 | // Identify instances by prefixes! |
| 70 | - if (!isset(self::$instances[$prefix])) { | |
| 71 | - self::$instances[$prefix] = new CJT_Framework_Autoload_Loader($prefix, $path); | |
| 65 | + if (!isset($instances[$prefix])) { | |
| 66 | + $instances[$prefix] = new CJT_Framework_Autoload_Loader($prefix, $path); | |
| 72 | 67 | } |
| 73 | - return isset(self::$instances[$prefix]) ? self::$instances[$prefix] : null; | |
| 68 | + return $instances[$prefix]; | |
| 74 | 69 | } |
| 75 | - | |
| 70 | + | |
| 76 | 71 | /** |
| 77 | - * Get an already registered loader by its exact prefix. | |
| 78 | - * | |
| 79 | - * Unlike autoLoad() this never registers anything, so it is safe to call | |
| 80 | - * with a prefix that came from the request. | |
| 81 | - * | |
| 82 | - * @param string $prefix Loader prefix to look up. | |
| 83 | - * @return CJT_Framework_Autoload_Loader|null Loader when registered, NULL otherwise. | |
| 84 | - */ | |
| 85 | - public static function getRegisteredLoader($prefix) { | |
| 86 | - return isset(self::$instances[$prefix]) ? self::$instances[$prefix] : null; | |
| 87 | - } | |
| 88 | - | |
| 89 | - /** | |
| 90 | - * Find ClassAutoloader instance used for loading specific class. | |
| 91 | - * | |
| 92 | - * The method is using Prefix algorithm for finding class autoloader | |
| 93 | - * | |
| 94 | - * @param mixed $className | |
| 95 | - */ | |
| 96 | - public static function & findClassLoader($className) { | |
| 97 | - # Getting class prefix | |
| 98 | - $classComponents = explode('_', $className); | |
| 99 | - $prefix = $classComponents[0]; | |
| 100 | - # Find autoloader | |
| 101 | - $instance = isset(self::$instances[$prefix]) ? self::$instances[$prefix] : null; | |
| 102 | - return $instance; | |
| 103 | - } | |
| 104 | - | |
| 105 | - /** | |
| 106 | 72 | * put your comment there... |
| 107 | 73 | * |
| 108 | 74 | * @param mixed $clsName |
| 109 | 75 | */ |
| @@ -151,24 +117,8 @@ | ||
| 151 | 117 | $component = $this->getClassComponent($name); |
| 152 | 118 | // Get class absolute path. |
| 153 | 119 | $path = $this->path . DIRECTORY_SEPARATOR . $component->path; |
| 154 | 120 | return $path . DIRECTORY_SEPARATOR . $file; |
| 155 | - } | |
| 156 | - | |
| 157 | - /** | |
| 158 | - * put your comment there... | |
| 159 | - * | |
| 160 | - */ | |
| 161 | - public function getPath() { | |
| 162 | - return $this->path; | |
| 163 | - } | |
| 164 | - | |
| 165 | - /** | |
| 166 | - * put your comment there... | |
| 167 | - * | |
| 168 | - */ | |
| 169 | - public function getPrefix() { | |
| 170 | - return $this->prefix; | |
| 171 | 121 | } |
| 172 | 122 | |
| 173 | 123 | /** |
| 174 | 124 | * put your comment there... |