Library Class. More...
Public Member Functions | |
| __construct ($cache_dir=false) | |
| Constructor. | |
| add ($name, array $options=array()) | |
| Add a library to discover. | |
| autoload ($classname) | |
| __autoload implementation | |
| register () | |
Data Fields | |
| const | CACHE_FILE = 'library.cache.php' |
Protected Member Functions | |
| _includeAll () | |
| Crawls all the registered path to locate the library files according to the extension(s) provided as options. | |
| _load ($classname) | |
| Tries to load the given class file. | |
| _cache () | |
| Stores the local class cache in file for later use. | |
Protected Attributes | |
| $_directories | |
| Library directories. | |
| $_classes | |
| Registered classes. | |
| $_cache_dir | |
| Cache dir path (false if cache is disabled) | |
| $_regenerate_flag = true | |
| Flag to tell if the library paths have been crawled. | |
Library Class.
This class is inspired by Gerald's Blog.
Delespierre 1.2.0 Copyright 2010-2011, Benjamin Delespierre (http://bdelespierre.fr) License: http://www.gnu.org/licenses/lgpl.html Lesser General Public Licence version 3
Definition at line 21 of file axLibrary.class.php.
| axLibrary::__construct | ( | $ | cache_dir = false | ) |
Constructor.
Takes the cache directory path as only parameter.
| string | $cache_dir | [optional] [default false] The cache directory (or false to disable the cache) |
Definition at line 65 of file axLibrary.class.php.
| axLibrary::_cache | ( | ) | [protected] |
Stores the local class cache in file for later use.
Does nothing if the cache is not activated.
Definition at line 189 of file axLibrary.class.php.
| axLibrary::_includeAll | ( | ) | [protected] |
Crawls all the registered path to locate the library files according to the extension(s) provided as options.
Definition at line 146 of file axLibrary.class.php.
| axLibrary::_load | ( | $ | classname | ) | [protected] |
Tries to load the given class file.
| string | $classname |
Definition at line 171 of file axLibrary.class.php.
| axLibrary::add | ( | $ | name, |
| array $ | options = array() |
||
| ) |
Add a library to discover.
The class file must be named according to the classname:
MyClass has to be named MyClass.php (pay attention to the case sensitiveness) .class.php but you may use the extension you want as long as you specify it in the $options parameter.| string | $name | The name of a folder located in /libraries or /application/libraries, or a path |
| array | $options | [optional] [default array()] |
| RuntimeException | If the library path cannot be found |
Definition at line 90 of file axLibrary.class.php.
| axLibrary::autoload | ( | $ | classname | ) |
__autoload implementation
Will seek for the $classname in the local cache and include the proper file if found.
| string | $classname |
| axClassNotFoundException | If such class can not be found, even after a library crawl |
Definition at line 118 of file axLibrary.class.php.
Register current instance as autoloader
Definition at line 136 of file axLibrary.class.php.
string axLibrary::$_cache_dir [protected] |
Cache dir path (false if cache is disabled)
Definition at line 45 of file axLibrary.class.php.
array axLibrary::$_classes [protected] |
Registered classes.
Definition at line 39 of file axLibrary.class.php.
array axLibrary::$_directories [protected] |
Library directories.
Definition at line 33 of file axLibrary.class.php.
boolean axLibrary::$_regenerate_flag = true [protected] |
Flag to tell if the library paths have been crawled.
This flag takes 2 possible values
Definition at line 56 of file axLibrary.class.php.
| const axLibrary::CACHE_FILE = 'library.cache.php' |
Definition at line 27 of file axLibrary.class.php.