Properties

$services

$services : array

Services

Type

array

$loaded

$loaded : array

Services that are loaded (instantiated)

Type

array

$depth

$depth : array

Recursion depth level tracker

Type

array

$called

$called : array

Recursion called service name tracker

Type

array

Methods

__construct()

__construct(array  $services = null, boolean  $default = true) 

Constructor

Instantiate the service locator object.

Parameters

array $services
boolean $default

Throws

\Pop\Service\Exception

setServices()

setServices(array  $services) : \Pop\Service\Locator

Set service objects from an array of services

Parameters

array $services

Throws

\Pop\Service\Exception

Returns

\Pop\Service\Locator

set()

set(string  $name, mixed  $service) : \Pop\Service\Locator

Set a service. It will overwrite any previous service with the same name.

A service can be a CallableObject, callable string, or an array that contains a 'call' key and an optional 'params' key. Valid callable strings are:

'someFunction'
'SomeClass'
'SomeClass->foo'
'SomeClass::bar'

Parameters

string $name
mixed $service

Throws

\Pop\Service\Exception

Returns

\Pop\Service\Locator

get()

get(string  $name) : mixed

Get/load a service

Parameters

string $name

Throws

\Pop\Service\Exception

Returns

mixed

getCall()

getCall(string  $name) : mixed

Get a service's callable string or object

Parameters

string $name

Returns

mixed

hasParams()

hasParams(string  $name) : boolean

Check if a service has parameters

Parameters

string $name

Returns

boolean

getParams()

getParams(string  $name) : mixed

Get a service's parameters

Parameters

string $name

Returns

mixed

setCall()

setCall(string  $name, mixed  $call) : \Pop\Service\Locator

Set a service's callable string or object

Parameters

string $name
mixed $call

Returns

\Pop\Service\Locator

setParams()

setParams(string  $name, mixed  $params) : \Pop\Service\Locator

Set a service's parameters

Parameters

string $name
mixed $params

Returns

\Pop\Service\Locator

addParam()

addParam(string  $name, mixed  $param, mixed  $key = null) : \Pop\Service\Locator

Add to a service's parameters

Parameters

string $name
mixed $param
mixed $key

Returns

\Pop\Service\Locator

removeParam()

removeParam(string  $name, mixed  $param, mixed  $key = null) : \Pop\Service\Locator

Remove a service's parameters

Parameters

string $name
mixed $param
mixed $key

Returns

\Pop\Service\Locator

isAvailable()

isAvailable(string  $name) : boolean

Determine of a service object is available (but not loaded)

Parameters

string $name

Returns

boolean

isLoaded()

isLoaded(string  $name) : boolean

Determine of a service object is loaded

Parameters

string $name

Returns

boolean

remove()

remove(string  $name) : \Pop\Service\Locator

Remove a service

Parameters

string $name

Returns

\Pop\Service\Locator

__set()

__set(string  $name, mixed  $value) : \Pop\Service\Locator

Set a service

Parameters

string $name
mixed $value

Throws

\Pop\Service\Exception

Returns

\Pop\Service\Locator

__get()

__get(string  $name) : mixed

Get a service

Parameters

string $name

Throws

\Pop\Service\Exception

Returns

mixed

__isset()

__isset(string  $name) : boolean

Determine if a service is available

Parameters

string $name

Returns

boolean

__unset()

__unset(string  $name) : \Pop\Service\Locator

Unset a service

Parameters

string $name

Returns

\Pop\Service\Locator

offsetSet()

offsetSet(string  $offset, mixed  $value) : \Pop\Service\Locator

Set a service

Parameters

string $offset
mixed $value

Throws

\Pop\Service\Exception

Returns

\Pop\Service\Locator

offsetGet()

offsetGet(string  $offset) : mixed

Get a service

Parameters

string $offset

Throws

\Pop\Service\Exception

Returns

mixed

offsetExists()

offsetExists(string  $offset) : boolean

Determine if a service is available

Parameters

string $offset

Returns

boolean

offsetUnset()

offsetUnset(string  $offset) : \Pop\Service\Locator

Unset a service

Parameters

string $offset

Returns

\Pop\Service\Locator

count()

count() : integer

Return count

Returns

integer

getIterator()

getIterator() : \ArrayIterator

Get iterator

Returns

\ArrayIterator