\Anax\DICDIFactoryDefault

Anax base class implementing Dependency Injection / Service Locator of the services used by the framework, using lazy loading.

Summary

Methods
Properties
Constants
__construct()
getServices()
getActiveServices()
set()
setShared()
get()
__get()
has()
__call()
$loaded
$active
No constants found
load()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$loaded

$loaded : 

Properties

Type

$active

$active : 

Type

Methods

__construct()

__construct() 

Construct.

getServices()

getServices() : void

Return an arry with all loaded services names.

getActiveServices()

getActiveServices() : void

Return an arry with all active services names.

set()

set(string  $service, mixed  $loader, boolean  $singleton = false) : \Anax\DI\nothing.

Set a service and connect it to a task which creates the object (lazy loading).

Parameters

string $service

as a service label, naming this service.

mixed $loader

contains a pre-defined object, a string with classname or an

 callable which returns an instance of the service object. Its the way to
 actually load, insantiate, the serviceobject.
boolean $singleton

set if service is to act as singleton or not, default is false.

Returns

\Anax\DI\nothing.

setShared()

setShared(string  $service, mixed  $loader) : \Anax\DI\nothing.

Set a singleton service and connect it to a task which creates the object (lazy loading).

Parameters

string $service

as a service label, naming this service.

mixed $loader

contains a pre-defined object, a string with classname or an

 callable which returns an instance of the service object. Its the way to
 actually load, insantiate, the serviceobject.

Returns

\Anax\DI\nothing.

get()

get(string  $service) : object

Get an instance of the service object, managing singletons.

Parameters

string $service

as a service label, naming this service.

Throws

\Anax\DI\Exception

when service accessed is not loaded.

Returns

object —

as instance of the service object.

__get()

__get(string  $service) : \Anax\DI\class

Magic method to get and create services.

When created it is also stored as a parameter of this object.

Parameters

string $service

name of class property not existing.

Returns

\Anax\DI\class —

as the service requested.

has()

has(string  $service) : boolean

Check if service exists by name.

Parameters

string $service

as a service label, naming this service.

Returns

boolean —

true if the service exists, otherwise false.

__call()

__call(string  $service, array  $arguments = array()) : \Anax\DI\class

Magic method to get and create services.

When created it is also stored as a parameter of this object.

Parameters

string $service

name of class property not existing.

array $arguments

currently NOT USED.

Returns

\Anax\DI\class —

as the service requested.

load()

load(string  $service) : object

Lazy load a service object and create an instance of it.

Parameters

string $service

as a service label, naming this service.

Throws

\Anax\DI\Exception

when service could not be loaded.

Returns

object —

as instance of the service object.