more refactoring and changes.
This commit is contained in:
@@ -3,35 +3,34 @@
|
||||
class Loader {
|
||||
|
||||
/**
|
||||
* The paths to be searched by the loader.
|
||||
* The paths that will be searched by the loader.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $paths;
|
||||
public $paths;
|
||||
|
||||
/**
|
||||
* All of the class aliases.
|
||||
* The class aliases defined for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $aliases;
|
||||
public $aliases;
|
||||
|
||||
/**
|
||||
* Bootstrap the auto-loader.
|
||||
* Create a new class loader instance.
|
||||
*
|
||||
* @param array $paths
|
||||
* @param array $aliases
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($aliases, $paths)
|
||||
public function __construct($paths, $aliases)
|
||||
{
|
||||
$this->paths = $paths;
|
||||
$this->aliases = $aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a class file for a given class name.
|
||||
*
|
||||
* This function is registered on the SPL auto-loader stack by the front controller during each request.
|
||||
* All Laravel class names follow a namespace to directory convention.
|
||||
* Load the file for a given class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return void
|
||||
@@ -45,9 +44,9 @@ class Loader {
|
||||
return class_alias($this->aliases[$class], $class);
|
||||
}
|
||||
|
||||
foreach ($this->paths as $directory)
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
if (file_exists($path = $directory.$file.EXT))
|
||||
if (file_exists($path = $path.$file.EXT))
|
||||
{
|
||||
require_once $path;
|
||||
|
||||
@@ -56,39 +55,4 @@ class Loader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a path with the auto-loader.
|
||||
*
|
||||
* After registering the path, it will be checked similarly to the models and libraries directories.
|
||||
*
|
||||
* @param string $path
|
||||
* @return void
|
||||
*/
|
||||
public function register_path($path)
|
||||
{
|
||||
$this->paths[] = rtrim($path, '/').'/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an alias with the auto-loader.
|
||||
*
|
||||
* @param array $alias
|
||||
* @return void
|
||||
*/
|
||||
public function register_alias($alias)
|
||||
{
|
||||
$this->aliases = array_merge($this->aliases, $alias);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an alias from the auto-loader's list of aliases.
|
||||
*
|
||||
* @param string $alias
|
||||
* @return void
|
||||
*/
|
||||
public function forget_alias($alias)
|
||||
{
|
||||
unset($this->aliases[$alias]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user