Application
Libraries
mixed Application::getLibrary(string name)
Returns an instance of the requested library, if that library was previously loaded, and an instance of it has been created.
Registry Application::getLibraries()
Returns a Registry object containing all the libraries loaded up to that point.
Loading a library
Libraries can be loaded at any point in your application, after the action has been dispatched to the controller. The method prototype looks like this:
mixed Application::loadLibrary(string name[, array params = array()[, string directory = null[, bool return_instance = false]]])
Parameters
- name: the library to load. The source file has to be placed in the includes/libraries/ directory and must be named name.php. Also, the class defined within this source file must be called name
- params: additional parameters that you want to be passed in to the library constructor upon initialization (this is only taken in account if return_instance is true)
- directory: the subdirectory within the includes/libraries/ directory which contains the source file for the requested library. Example: if you want to load a library that is named "Test", and it's source file resides in a directory called "MyLib" within the includes/libraries/ directory, then you will pass in the name Test, and the directory MyLib
- return_instance: if this parameters is set to true, an instance of the library will be created and stored into the Application internal data store for caching purposes. The next time you request the same library, this instance will be returned
Return values
- boolean: if the return_instance parameter is true, an object of type name will be returned
- object: if the return_instance parameter is false, a boolean value will be returned. true means that the library has been successfully loaded, while false is returned if any error occured
This method will always throw an IOException exception if the library source file was not found.