| @@ -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,32 +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 | - * Find ClassAutoloader instance used for loading specific class. | |
| 78 | - * | |
| 79 | - * The method is using Prefix algorithm for finding class autoloader | |
| 80 | - * | |
| 81 | - * @param mixed $className | |
| 82 | - */ | |
| 83 | - public static function & findClassLoader($className) { | |
| 84 | - # Getting class prefix | |
| 85 | - $classComponents = explode('_', $className); | |
| 86 | - $prefix = $classComponents[0]; | |
| 87 | - # Find autoloader | |
| 88 | - $instance = isset(self::$instances[$prefix]) ? self::$instances[$prefix] : null; | |
| 89 | - return $instance; | |
| 90 | - } | |
| 91 | - | |
| 92 | - /** | |
| 93 | 72 | * put your comment there... |
| 94 | 73 | * |
| 95 | 74 | * @param mixed $clsName |
| 96 | 75 | */ |
| @@ -143,24 +122,8 @@ | ||
| 143 | 122 | |
| 144 | 123 | /** |
| 145 | 124 | * put your comment there... |
| 146 | 125 | * |
| 147 | - */ | |
| 148 | - public function getPath() { | |
| 149 | - return $this->path; | |
| 150 | - } | |
| 151 | - | |
| 152 | - /** | |
| 153 | - * put your comment there... | |
| 154 | - * | |
| 155 | - */ | |
| 156 | - public function getPrefix() { | |
| 157 | - return $this->prefix; | |
| 158 | - } | |
| 159 | - | |
| 160 | - /** | |
| 161 | - * put your comment there... | |
| 162 | - * | |
| 163 | 126 | * @param mixed $class |
| 164 | 127 | */ |
| 165 | 128 | public function loadClass($class) { |
| 166 | 129 | $classFile = ''; |
| @@ -174,9 +137,9 @@ | ||
| 174 | 137 | // Get class paths. |
| 175 | 138 | $classFile = $this->getClassAbsolutePath($this->getClassComponent($class)); |
| 176 | 139 | } |
| 177 | 140 | // Whatever a class file is set, import it! |
| 178 | - if ($classFile && file_exists($classFile)) { | |
| 141 | + if ($classFile) { | |
| 179 | 142 | require $classFile; |
| 180 | 143 | } |
| 181 | 144 | } |
| 182 | 145 | |