mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-29 00:34:03 +02:00
parent
a382a563d5
commit
ac99e54f17
@ -5,6 +5,9 @@ namespace Icinga\Application;
|
|||||||
|
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PSR-4 class loader
|
||||||
|
*/
|
||||||
class ClassLoader
|
class ClassLoader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -13,14 +16,14 @@ class ClassLoader
|
|||||||
const NAMESPACE_SEPARATOR = '\\';
|
const NAMESPACE_SEPARATOR = '\\';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of namespaces
|
* Namespaces
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $namespaces = array();
|
private $namespaces = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register new namespace for directory
|
* Register a base directory for a namespace prefix
|
||||||
*
|
*
|
||||||
* @param string $namespace
|
* @param string $namespace
|
||||||
* @param string $directory
|
* @param string $directory
|
||||||
@ -44,9 +47,9 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if a namespace exists
|
* Test whether a namespace exists
|
||||||
*
|
*
|
||||||
* @param string $namespace
|
* @param string $namespace
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@ -56,13 +59,11 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class loader
|
* Load the given class or interface
|
||||||
*
|
*
|
||||||
* Ignores all but classes in registered namespaces.
|
* @param string $class Name of the class or interface
|
||||||
*
|
*
|
||||||
* @param string $class
|
* @return bool Whether the class or interface has been loaded
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
*/
|
||||||
public function loadClass($class)
|
public function loadClass($class)
|
||||||
{
|
{
|
||||||
@ -82,7 +83,7 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if we have a registered namespaces for this class
|
* Get the namespace for the given class
|
||||||
*
|
*
|
||||||
* Return is the longest match in the array found
|
* Return is the longest match in the array found
|
||||||
*
|
*
|
||||||
@ -114,17 +115,15 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effectively registers the autoloader the PHP/SPL way
|
* Register {@link loadClass()} as an autoloader
|
||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
// Think about to add class pathes to php include path
|
|
||||||
// this could be faster (tg)
|
|
||||||
spl_autoload_register(array($this, 'loadClass'));
|
spl_autoload_register(array($this, 'loadClass'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detach autoloader from spl registration
|
* Unregister {@link loadClass()} as an autoloader
|
||||||
*/
|
*/
|
||||||
public function unregister()
|
public function unregister()
|
||||||
{
|
{
|
||||||
@ -132,7 +131,7 @@ class ClassLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detach spl autoload method from stack
|
* Unregister this as an autloader
|
||||||
*/
|
*/
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user