lithium\core\Libraries::load()
Loads the class definition specified by $class
. Looks through the list of libraries
defined in $_configurations
, which are added through lithium\core\Libraries::add()
.
Parameters
-
string
$class
The fully-namespaced (where applicable) name of the class to load.
-
boolean
$require
Specifies whether the class must be loaded or considered an exception. Defaults to
false
.
Returns
voidSource
public static function load($class, $require = false) {
$path = isset(static::$_cachedPaths[$class]) ? static::$_cachedPaths[$class] : null;
$path = $path ?: static::path($class);
if ($path && include $path) {
static::$_cachedPaths[$class] = $path;
if (method_exists($class, '__init')) {
$message = "Support for automatic initialization of static classes has been ";
$message .= "removed. `{$class}::__init()` exists, please remove it to get rid ";
$message .= "of this message. Static classes must now be initialized manually. ";
$message .= "i.e. by creating an `init()` method and calling it at the end of ";
$message .= "the file and outside of the class.";
throw new RuntimeException($message);
}
} elseif ($require) {
throw new RuntimeException("Failed to load class `{$class}` from path `{$path}`.");
}
}