cleaning up code.

This commit is contained in:
Taylor Otwell 2012-04-10 22:36:20 -05:00
parent 9ad6fabc02
commit 8bc128fdaa
2 changed files with 18 additions and 30 deletions

View File

@ -1,4 +1,4 @@
<?php namespace Laravel; defined('DS') or die('No direct script access.');
<?php namespace Laravel;
class Asset {

View File

@ -1,4 +1,4 @@
<?php namespace Laravel; defined('DS') or die('No direct script access.');
<?php namespace Laravel;
class Autoloader {
@ -52,7 +52,7 @@ public static function load($class)
// called again for the "real" class name to load its file.
if (isset(static::$aliases[$class]))
{
class_alias(static::$aliases[$class], $class);
return class_alias(static::$aliases[$class], $class);
}
// All classes in Laravel are staticly mapped. There is no crazy search
@ -76,17 +76,6 @@ class_alias(static::$aliases[$class], $class);
}
}
// If the class uses PEAR-ish style underscores for indicating its
// directory structure we'll load the class using PSR-0 standards
// standards from that directory, trimming the root.
foreach (static::$underscored as $prefix => $directory)
{
if (starts_with($class, $prefix))
{
return static::load_namespaced($class, $prefix, $directory);
}
}
// If all else fails we will just iterator through the mapped
// PSR-0 directories looking for the class. This is the last
// resort and slowest loading option for the class.
@ -176,6 +165,20 @@ public static function directories($directory)
static::$directories = array_unique(array_merge(static::$directories, $directories));
}
/**
* Map namespaces to directories.
*
* @param array $mappings
* @param string $append
* @return void
*/
public static function namespaces($mappings, $append = '\\')
{
$mappings = static::format_mappings($mappings, $append);
static::$namespaces = array_merge($mappings, static::$namespaces);
}
/**
* Register underscored "namespaces" to directory mappings.
*
@ -184,22 +187,7 @@ public static function directories($directory)
*/
public static function underscored($mappings)
{
$mappings = static::format_mappings($mappings, '_');
static::$underscored = array_merge($mappings, static::$underscored);
}
/**
* Map namespaces to directories.
*
* @param array $mappings
* @return void
*/
public static function namespaces($mappings)
{
$mappings = static::format_mappings($mappings, '\\');
static::$namespaces = array_merge($mappings, static::$namespaces);
static::namespaces($mappings, '_');
}
/**