|
|
@ -266,12 +266,9 @@ class BaseYii |
|
|
|
* 2. If the class is namespaced (e.g. `yii\base\Component`), it will attempt |
|
|
|
* 2. If the class is namespaced (e.g. `yii\base\Component`), it will attempt |
|
|
|
* to include the file associated with the corresponding path alias |
|
|
|
* to include the file associated with the corresponding path alias |
|
|
|
* (e.g. `@yii/base/Component.php`); |
|
|
|
* (e.g. `@yii/base/Component.php`); |
|
|
|
* 3. If the class is named in PEAR style (e.g. `PHPUnit_Framework_TestCase`), |
|
|
|
|
|
|
|
* it will attempt to include the file associated with the corresponding path alias |
|
|
|
|
|
|
|
* (e.g. `@PHPUnit/Framework/TestCase.php`); |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* This autoloader allows loading classes that follow the [PSR-0 standard](http://www.php-fig.org/psr/0/). |
|
|
|
* This autoloader allows loading classes that follow the [PSR-4 standard](http://www.php-fig.org/psr/psr-4/) |
|
|
|
* Therefor a path alias has to be defined for each top-level namespace. |
|
|
|
* and have its top-level namespace defined as path aliases. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param string $className the fully qualified class name without a leading backslash "\" |
|
|
|
* @param string $className the fully qualified class name without a leading backslash "\" |
|
|
|
* @throws UnknownClassException if the class does not exist in the class file |
|
|
|
* @throws UnknownClassException if the class does not exist in the class file |
|
|
@ -283,25 +280,13 @@ class BaseYii |
|
|
|
if ($classFile[0] === '@') { |
|
|
|
if ($classFile[0] === '@') { |
|
|
|
$classFile = static::getAlias($classFile); |
|
|
|
$classFile = static::getAlias($classFile); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} elseif (strpos($className, '\\') !== false) { |
|
|
|
// follow PSR-0 to determine the class file |
|
|
|
$classFile = static::getAlias('@' . str_replace('\\', '/', $className) . '.php', false); |
|
|
|
if (($pos = strrpos($className, '\\')) !== false) { |
|
|
|
|
|
|
|
// namespaced class, e.g. yii\base\Component |
|
|
|
|
|
|
|
$path = str_replace('\\', '/', substr($className, 0, $pos + 1)) |
|
|
|
|
|
|
|
. str_replace('_', '/', substr($className, $pos + 1)) . '.php'; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$path = str_replace('_', '/', $className) . '.php'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// try loading via path alias |
|
|
|
|
|
|
|
if (strpos($path, '/') === false) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$classFile = static::getAlias('@' . $path, false); |
|
|
|
|
|
|
|
if ($classFile === false || !is_file($classFile)) { |
|
|
|
if ($classFile === false || !is_file($classFile)) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
include($classFile); |
|
|
|
include($classFile); |
|
|
|