\Pop\ServiceLocator

Service locator class

Summary

Methods
Properties
Constants
__construct()
setServices()
set()
get()
getCall()
getParams()
setCall()
setParams()
isAvailable()
isLoaded()
remove()
__set()
__get()
__isset()
__unset()
offsetSet()
offsetGet()
offsetExists()
offsetUnset()
No public properties found
No constants found
No protected methods found
$services
$loaded
N/A
No private methods found
$depth
$called
N/A

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) : \Pop\Service\Locator

Constructor

Instantiate the service locator object.

Parameters

array $services

Returns

\Pop\Service\Locator

setServices()

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

Set service objects from an array of services

Parameters

array $services

Returns

\Pop\Service\Locator

set()

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

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

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

'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

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

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

Returns

\Pop\Service\Locator

__get()

__get(string  $name) : mixed

Get a service

Parameters

string $name

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

Returns

\Pop\Service\Locator

offsetGet()

offsetGet(string  $offset) : mixed

Get a service

Parameters

string $offset

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