Axiom (v1.2.0)

A lightweight PHP framework
axLibrary Class Reference

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.

Detailed Description

Library Class.

Todo:
axLibrary long description here

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.


Constructor & Destructor Documentation

axLibrary::__construct ( cache_dir = false)

Constructor.

Takes the cache directory path as only parameter.

Parameters:
string$cache_dir[optional] [default false] The cache directory (or false to disable the cache)

Definition at line 65 of file axLibrary.class.php.


Member Function Documentation

axLibrary::_cache ( ) [protected]

Stores the local class cache in file for later use.

Does nothing if the cache is not activated.

Returns:
boolean

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.

See also:
axLibrary::add()
Returns:
void

Definition at line 146 of file axLibrary.class.php.

axLibrary::_load ( classname) [protected]

Tries to load the given class file.

Parameters:
string$classname
Returns:
boolean

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:

  • for instance, the file for MyClass has to be named MyClass.php (pay attention to the case sensitiveness)
  • the extension is arbitrary (Axiom classes uses .class.php but you may use the extension you want as long as you specify it in the $options parameter.
Note:
You may pass a $options parameters to set file extensions for the library or to ask for a recursive inclusion. A reccursive inclusion consist of a complete directory tree traversing to find the class files.
Warning:
This class CANNOT handle more than one class per file for now.
Parameters:
string$nameThe name of a folder located in /libraries or /application/libraries, or a path
array$options[optional] [default array()]
Exceptions:
RuntimeExceptionIf the library path cannot be found
Returns:
axLibrary

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.

Parameters:
string$classname
Exceptions:
axClassNotFoundExceptionIf such class can not be found, even after a library crawl
Returns:
boolean

Definition at line 118 of file axLibrary.class.php.

Register current instance as autoloader

Returns:
boolean

Definition at line 136 of file axLibrary.class.php.


Field Documentation

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

  • true : crawl is possible
  • false: crawl has been done before and will not be done again

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.


The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables