\Anax\DIDIFactoryDefault

DI factory class creating a set of default services into the DI container.

Summary

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

Properties

$loaded

$loaded : array

Type

array — Store all lazy loaded services, ready to be instantiated.

$active

$active : 

Type

Methods

createDefaultServices()

createDefaultServices() : self

Create a set of basic services useful for a website.

Returns

self

get()

get(string  $service) : mixed

Finds an entry in the container by its identifier and returns it.

If the service is active/singelton then that instance is returned, else the service is loaded and a new instance is returned.

Parameters

string $service

Identifier of the entry to look for.

Throws

\Anax\DI\Exception\NotFoundException

No entry was found for this identifier.

\Anax\DI\Exception\Exception

Error while retrieving the entry.

Returns

mixed —

Entry.

has()

has(string  $service) : boolean

Returns true if the container can return an entry for the given identifier, otherwise false

has($id) returning true does not mean that get($id) will not throw an exception. It does however mean that get($id) will not throw a NotFoundException.

Parameters

string $service

Identifier of the entry to look for.

Returns

boolean

set()

set(string  $service, mixed  $loader) : void

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 class name or an callable which returns an instance of the service object. Its the way to actually load, insantiate, the service object.

setShared()

setShared(string  $service, mixed  $loader) : void

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 class name or an callable which returns an instance of the service object. Its the way to actually load, insantiate, the service object.

getServices()

getServices() : void

Return an arry with all loaded services names.

getActiveServices()

getActiveServices() : void

Return an arry with all active services names.

__construct()

__construct() 

Constructor creating a set of services included into this DI container.

load()

load(string  $service) : object

Load a prepared service object and create an instance of it.

Parameters

string $service

as a service label, naming this service.

Throws

\Anax\DI\Exception\Exception

when service could not be loaded.

Returns

object —

as instance of the service object.