4.5. Opl_Loader class
4.5.1. addLibrary()
4.5. Opl_Loader class
« Previous
4.5.2. autoload()
Next »

4.5.1. addLibrary()

ConstructStatic method
Visibilitypublic
Referencevoid addLibrary(string $library, array $config);
Argument list
$library - string
The library name and prefix of its classes.
$config - array
The library configuration.
Versionssince 2.0-RC1

Adds the specific settings for the library $library. The rules will be applied to all the classes beginning with the prefix $library. The allowed settings are:

By default, the autoloader uses the OPL handler. If you are going to use the autoloader with non-OPL libraries, you should disable it for them.

Opl_Loader::addLibrary('Foo', array('directory' => './foo', 'handler' => 'myHandlerFunction'));
Opl_Loader::load('Foo_Class');

The example above will load the Foo_Class source code from the ./foo/ directory and use the myHandlerFunction to deal with some specific autoloading needs.

Library handlers

The standard autoloader converts the class name to the file name by replacing the underscores with the directory separator and adding the .php file extension. However, some libraries may have some specific needs. For example, in OPL the autoloader must perform the following extra actions:

Such needs are supported with external handlers. If your library needs one, with this method you can add it. The handler must be an ordinary function or class method:

boolean autoloadingHandler(string $library, string $className)

The method must return true, if the autoloader should still load the file using the standard rules and false, if the handler has already found and loaded the requested class.

See also:

4.5.1. addLibrary()
4.5. Opl_Loader class
« Previous
4.5. Opl_Loader class
Next »
4.5.2. autoload()