simplify autoloader namespace mapping.
Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
This commit is contained in:
parent
909413916c
commit
a08537335a
|
@ -56,14 +56,16 @@ class_alias(static::$aliases[$class], $class);
|
|||
require static::$mappings[$class];
|
||||
}
|
||||
|
||||
$namespace = root_namespace($class).'\\';
|
||||
|
||||
// If the class namespace is mapped to a directory, we will load the
|
||||
// class using the PSR-0 standards from that directory accounting
|
||||
// for the root of the namespace by trimming it.
|
||||
if ( ! is_null($info = static::namespaced($class)))
|
||||
if (isset(static::$namespaces[$namespace]))
|
||||
{
|
||||
$class = substr($class, strlen($info['namespace']));
|
||||
$class = substr($class, strlen($namespace));
|
||||
|
||||
return static::load_psr($class, $info['directory']);
|
||||
return static::load_psr($class, static::$namespaces[$namespace]);
|
||||
}
|
||||
|
||||
static::load_psr($class);
|
||||
|
@ -103,23 +105,6 @@ protected static function load_psr($class, $directory = null)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the directory for a given namespaced class.
|
||||
*
|
||||
* @param string $class
|
||||
* @return string
|
||||
*/
|
||||
protected static function namespaced($class)
|
||||
{
|
||||
foreach (static::$namespaces as $namespace => $directory)
|
||||
{
|
||||
if (starts_with($class, $namespace))
|
||||
{
|
||||
return compact('namespace', 'directory');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an array of class to path mappings.
|
||||
*
|
||||
|
|
|
@ -216,7 +216,7 @@ public function slider($adjacent = 3)
|
|||
//
|
||||
// Likewise, if the page is very close to the end, we will create the
|
||||
// beginning of the slider, but just show the last several pages at
|
||||
// the end of the slider.
|
||||
// the end of the slider. Otherwise, we'll build the range.
|
||||
//
|
||||
// Example: 1 [2] 3 4 5 6 ... 23 24
|
||||
if ($this->page <= $window)
|
||||
|
|
Loading…
Reference in New Issue