cleaning up the auto-loader.
This commit is contained in:
parent
618980c678
commit
94b4887000
|
@ -102,31 +102,19 @@ class_alias(static::$aliases[$class], $class);
|
|||
*/
|
||||
protected static function load_psr($class, $directory = null)
|
||||
{
|
||||
// The PSR-0 standard indicates that class namespace slashes or
|
||||
// underscores should be used to indicate the directory tree in
|
||||
// which the class resides, so we'll convert the namespace
|
||||
// slashes to directory slashes.
|
||||
// The PSR-0 standard indicates that class namespaces and underscores
|
||||
// shoould be used to indcate the directory tree in which the class
|
||||
// resides, so we'll convert them to directory slashes.
|
||||
$file = str_replace(array('\\', '_'), '/', $class);
|
||||
|
||||
if (is_null($directory))
|
||||
{
|
||||
$directories = static::$psr;
|
||||
}
|
||||
else
|
||||
{
|
||||
$directories = array($directory);
|
||||
}
|
||||
$directories = $directory ?: static::$psr;
|
||||
|
||||
// Once we have formatted the class name, we will simply spin
|
||||
// through the registered PSR-0 directories and attempt to
|
||||
// locate and load the class into the script.
|
||||
//
|
||||
// We will check for both lowercase and CamelCase files as
|
||||
// Laravel uses a lowercase version of PSR-0, while true
|
||||
// PSR-0 uses CamelCase for all file names.
|
||||
$lower = strtolower($file);
|
||||
|
||||
foreach ($directories as $directory)
|
||||
// Once we have formatted the class name, we'll simply spin through
|
||||
// the registered PSR-0 directories and attempt to locate and load
|
||||
// the class file into the script.
|
||||
foreach ((array) $directories as $directory)
|
||||
{
|
||||
if (file_exists($path = $directory.$lower.EXT))
|
||||
{
|
||||
|
@ -149,9 +137,6 @@ protected static function namespaced($class)
|
|||
{
|
||||
foreach (static::$namespaces as $namespace => $directory)
|
||||
{
|
||||
// If the class begins with one of the registered namespaces,
|
||||
// we'll return both the namespace and the directory, which
|
||||
// will allow us to use PSR-0 to load the class.
|
||||
if (starts_with($class, $namespace))
|
||||
{
|
||||
return compact('namespace', 'directory');
|
||||
|
@ -162,11 +147,6 @@ protected static function namespaced($class)
|
|||
/**
|
||||
* Register an array of class to path mappings.
|
||||
*
|
||||
* <code>
|
||||
* // Register a class mapping with the Autoloader
|
||||
* Autoloader::map(array('User' => path('app').'models/user.php'));
|
||||
* </code>
|
||||
*
|
||||
* @param array $mappings
|
||||
* @return void
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue