ZenMagick 0.9.1


org.zenmagick.ZMLoader

Class ZMLoader

ZMLoader

public class ZMLoader

ZenMagick code/class loader.

Loader might be chained to allow delegation of theme loading. All loader implement a parent first strategy.

Classes in ZenMagick have to adhere to the following conventions:

Note: This is not as scalable as Java code and does not handle more than on level of inheritance.

Static methods operate on the root loader.

Author:
mano
Version:
$Id: ZMLoader.php 1093 2008-05-09 03:25:37Z DerManoMann $

Constructor Summary

ZMLoader()

Create a new loader.

Method Summary
void

addPath(string path, boolean recursive)

Add a given path to the loaders path.

protected mixed

create(string name, var arg)

Resolve, load and instantiate a new instance of the given class.

static array

findIncludes(string dir, boolean recursive)

Scan (recursively) for .php files.

protected string

getClassFile(string name)

Get the class file for the given class name.

static array

getClassHierachy(mixed object)

Get class hierachy for the given class/object.

array

getClassPath(boolean includeParent)

Get the class path.

array

getStatic()

Returns a list of all the static code in this loaders path.

static ZMLoader

instance()

Get the root loader.

void

loadStatic()

Load all available static code.

static mixed

make(mixed args, string name, var arg)

Shortcut for creating new class instances.

static string

makeClassname(string filename)

Normalize class names based on the filename This is pretty much following Java conventions.

static string

resolve(string name)

Resolve and load the class code for the given class name.

static void

resolveZCClass(string clazz)

Resolve the given zen-cart class.

protected array

scan(string path, boolean recursive)

Scan the given path for PHP files.

void

setParent(mixed parent)

Set the parent loader.

Constructor Detail

ZMLoader

public ZMLoader()

Create a new loader. /


Method Detail

addPath

public void addPath(string path, boolean recursive)

Add a given path to the loaders path.

Parameters:
path - The path to add.
recursive - Flag to indicate if the path should be scanned recursively.

create

protected mixed create(string name, var arg)

Resolve, load and instantiate a new instance of the given class.

Parameters:
name - The class name (without the ZM prefix).
arg - Optional constructor arguments.
Returns:
A new instance of the given class.

findIncludes

public static array findIncludes(string dir, boolean recursive)

Scan (recursively) for .php files.

It is worth mentioning that directories will always be processed only after all plain files in a directory are done.

Parameters:
dir - The name of the root directory to scan.
recursive - If true, scan recursively.
Returns:
List of full filenames of .php files.

getClassFile

protected string getClassFile(string name)

Get the class file for the given class name.

Parameters:
name - The class name without the ZM prefix.
Returns:
The class filename that or null.

getClassHierachy

public static array getClassHierachy(mixed object)

Get class hierachy for the given class/object.

Parameters:
object - The object or class name.
Returns:
The class hierachy.

getClassPath

public array getClassPath(boolean includeParent)

Get the class path.

Parameters:
includeParent - If true include the parent loader path: default is true.
Returns:
Class path array.

getStatic

public array getStatic()

Returns a list of all the static code in this loaders path. Code is identified by a filename starting with a lower case character.

Note: This is an instance specific method. There is no delegation to a parent loader.

Returns:
Static files with local.php being the first (if it exists).

instance

public static ZMLoader instance()

Get the root loader.

Returns:
The root loader.

loadStatic

public void loadStatic()

Load all available static code.

Note: Using this is intended to load functions, defines, etc. As this is loaded inside a method, variables inside static files will not be real globals.

/


make

public static mixed make(mixed args, string name, var arg)

Shortcut for creating new class instances.

Parameters:
name - The class name (without the ZM prefix).
arg - Optional constructor arguments.
Returns:
A new instance of the given class.

makeClassname

public static string makeClassname(string filename)

Normalize class names based on the filename

This is pretty much following Java conventions.

Parameters:
filename - The filename.
Returns:
A corresponding class name.

resolve

public static string resolve(string name)

Resolve and load the class code for the given class name.

Parameters:
name - The class name without the ZM prefix.
Returns:
The resolved class name; this is either the given name, the ZenMagick default * implementation or null.

resolveZCClass

public static void resolveZCClass(string clazz)

Resolve the given zen-cart class.

This functuon ensures that the given class is loaded.

Parameters:
clazz - The class name.

scan

protected array scan(string path, boolean recursive)

Scan the given path for PHP files.

Parameters:
path - The path to scan.
recursive - Flag to indicate if the path should be scanned recursively.
Returns:
A file map for the given path.

setParent

public void setParent(mixed parent)

Set the parent loader. /


ZenMagick 0.9.1