LoaderAbstract is used for classes that chain from \Gems_Loader and that thus allow projects to overrule the original implementation.

I.e if you create a class _Model or _Util, that class is loaded automatically instead of \Gems_Model or \Gems_Util. _Model should be a subclass of \Gems_Model.

You can set more than one overrule level. I.e. you can specify the class chain Demopulse, Pulse, Gems. The loader will then always look first in Demopulse, then in Pulse and lastly in Gems.

The class inherits from \MUtil_Registry_Source as the chained classes may have values that should be set automatically, e.g. from \Zend_Registry.

package Gems
subpackage Model
copyright Copyright (c) 2011 Erasmus MC
license New BSD License
since Class available since version 1.2

 Methods

__construct()

__construct(mixed $container, array $dirs) 

Parameters

$container

mixed

A container acting as source for \MUtil_Registry_Source

$dirs

array

The directories where to look for requested classes

__get()

__get($name) 

Parameters

$name

Add prefixed paths to the registry of paths

addPrefixPath(string $prefix, $path, boolean $prepend = true) : \Gems_Loader_LoaderAbstract

Parameters

$prefix

string

$path

$prepend

boolean

Put path at the beginning of the stack (has no effect when prefix / dir already set)

Returns

\Gems_Loader_LoaderAbstract(continuation pattern)

Add a subdirectory / sub name to a list of class load paths

_cascadedDirs(array $dirs, string $cascade, boolean $fullClassnameFallback = true) : array

Parameters

$dirs

array

prefix => path

$cascade

string

The sub directories to cascade to

$fullClassnameFallback

boolean

Allows full class name specification instead of just plugin name part

Returns

arrayprefix => path

Returns $this->$name, creating the item if it does not yet exist.

_getClass(string $name, string $className = null, array $arguments = array()) : mixed

Parameters

$name

string

The $name of the variable to store this object in.

$className

string

Class name or null if the same as $name, prepending $this->_dirs.

$arguments

array

Class initialization arguments.

Returns

mixedInstance of $className

Create or loads the class. When only loading, this function returns a StaticCall object that can be invoked lazely.

_loadClass(string $name, boolean $create = false, array $arguments = array()) : mixed
see
see

Parameters

$name

string

The class name, minus the part in $this->_dirs.

$create

boolean

Create the object, or only when an \MUtil_Registry_TargetInterface instance.

$arguments

array

Class initialization arguments.

Returns

mixedA class instance or a \MUtil_Lazy_StaticCall object

 Properties

 

The prefix/path location to look for classes.

$_dirs : array

Default

The standard value is

  • => application/classes
  • Gems => library/Gems/classes

But an alternative could be:

  • Demopulse => application/classes
  • Pulse => application/classes
  • Gems => library/Gems/classes
 

$_loader

$_loader : \MUtil_Loader_PluginLoader

Default

 

Allows sub classes of \Gems_Loader_LoaderAbstract to specify the subdirectory where to look for.

$cascade : string

Default

null