Commit 94b48870 authored by Taylor Otwell's avatar Taylor Otwell

cleaning up the auto-loader.

parent 618980c6
......@@ -102,31 +102,19 @@ class Autoloader {
*/
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 @@ class Autoloader {
{
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 @@ class Autoloader {
/**
* 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
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment