Commit bc1a7d07 by Taylor Otwell

improving namespace autoloading support.

parent 5b6b156b
......@@ -64,10 +64,8 @@ class Autoloader {
// using the PSR-0 standards from that directory; however, we will trim
// off the beginning of the namespace to account for files in the root
// of the mapped directory.
if (isset(static::$namespaces[$namespace]))
if ( ! is_null($directory = static::directory($class)))
{
$directory = static::$namespaces[$namespace];
return static::load_psr(substr($class, $slash + 1), $directory);
}
......@@ -94,6 +92,23 @@ class Autoloader {
}
/**
* Get the directory associated with a given namespaced class.
*
* @param string $class
* @return string
*/
protected static function directory($class)
{
foreach (static::$namespaces as $namespace => $directory)
{
if (starts_with($class, $namespace))
{
return $directory;
}
}
}
/**
* Attempt to resolve a class using the PSR-0 standard.
*
* @param string $class
......
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