Locator
extends AbstractManager
in package
Service locator class
Tags
Table of Contents
Properties
- $items : array<string|int, mixed>
- Manager items
- $loaded : array<string|int, mixed>
- Services that are loaded/instantiated
- $called : array<string|int, mixed>
- Recursion called service name tracker
- $depth : int
- Recursion depth level tracker
Methods
- __construct() : mixed
- Constructor
- __get() : mixed
- Get a service
- __isset() : bool
- Determine if a service is available
- __set() : void
- Set a service
- __unset() : void
- Unset a service
- addItem() : static
- Add an item
- addItems() : static
- Add items
- addParameter() : static
- Add to a service's parameters
- count() : int
- Return count
- get() : mixed
- Get/load a service
- getCallable() : mixed
- Get a service's callable string or object
- getItem() : mixed
- Get an item
- getItems() : array<string|int, mixed>
- Get items
- getIterator() : ArrayIterator
- Get iterator
- getParameters() : mixed
- Get a service's parameters
- hasItem() : bool
- Determine whether the manager has an item
- hasItems() : bool
- Determine whether the manager has items
- hasParameter() : bool
- Check if a service has parameters
- isAvailable() : bool
- Determine of a service object is available (but not loaded)
- isLoaded() : bool
- Determine of a service object is loaded
- offsetExists() : bool
- Determine if a service is available
- offsetGet() : mixed
- Get a service
- offsetSet() : void
- Set a service
- offsetUnset() : void
- Unset a service
- reload() : mixed
- Re-load a service object
- remove() : static
- Remove a service
- removeItem() : static
- Remove an item
- removeParameters() : static
- Remove a service's parameters
- set() : static
- Set a service. It will overwrite any previous service with the same name.
- setCallable() : static
- Set a service's callable string or object
- setItems() : static
- Set items
- setParameters() : static
- Set a service's parameters
- setServices() : static
- Set service objects from an array of services
Properties
$items
Manager items
protected
array<string|int, mixed>
$items
= []
$loaded
Services that are loaded/instantiated
protected
array<string|int, mixed>
$loaded
= []
$called
Recursion called service name tracker
private
static array<string|int, mixed>
$called
= []
$depth
Recursion depth level tracker
private
static int
$depth
= 0
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed>|null $services = null ][, bool $default = true ]) : mixed
Instantiate the service locator object.
Parameters
- $services : array<string|int, mixed>|null = null
- $default : bool = true
Tags
__get()
Get a service
public
__get(string $name) : mixed
Parameters
- $name : string
Tags
__isset()
Determine if a service is available
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool__set()
Set a service
public
__set(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
Tags
__unset()
Unset a service
public
__unset(string $name) : void
Parameters
- $name : string
addItem()
Add an item
public
addItem(mixed $item[, mixed $name = null ]) : static
Parameters
- $item : mixed
- $name : mixed = null
Return values
staticaddItems()
Add items
public
addItems(array<string|int, mixed> $items) : static
Parameters
- $items : array<string|int, mixed>
Return values
staticaddParameter()
Add to a service's parameters
public
addParameter(string $name, mixed $param[, mixed $key = null ]) : static
Parameters
- $name : string
- $param : mixed
- $key : mixed = null
Return values
staticcount()
Return count
public
count() : int
Return values
intget()
Get/load a service
public
get(string $name) : mixed
Parameters
- $name : string
Tags
getCallable()
Get a service's callable string or object
public
getCallable(string $name) : mixed
Parameters
- $name : string
getItem()
Get an item
public
getItem(mixed $name) : mixed
Parameters
- $name : mixed
getItems()
Get items
public
getItems() : array<string|int, mixed>
Return values
array<string|int, mixed>getIterator()
Get iterator
public
getIterator() : ArrayIterator
Return values
ArrayIteratorgetParameters()
Get a service's parameters
public
getParameters(string $name) : mixed
Parameters
- $name : string
hasItem()
Determine whether the manager has an item
public
hasItem(string $name) : bool
Parameters
- $name : string
Return values
boolhasItems()
Determine whether the manager has items
public
hasItems() : bool
Return values
boolhasParameter()
Check if a service has parameters
public
hasParameter(string $name) : bool
Parameters
- $name : string
Return values
boolisAvailable()
Determine of a service object is available (but not loaded)
public
isAvailable(string $name) : bool
Parameters
- $name : string
Return values
boolisLoaded()
Determine of a service object is loaded
public
isLoaded(string $name) : bool
Parameters
- $name : string
Return values
booloffsetExists()
Determine if a service is available
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
Get a service
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
Tags
offsetSet()
Set a service
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Tags
offsetUnset()
Unset a service
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
reload()
Re-load a service object
public
reload(string $name) : mixed
Parameters
- $name : string
remove()
Remove a service
public
remove(string $name) : static
Parameters
- $name : string
Return values
staticremoveItem()
Remove an item
public
removeItem(mixed $name) : static
Parameters
- $name : mixed
Return values
staticremoveParameters()
Remove a service's parameters
public
removeParameters(string $name, mixed $param[, mixed $key = null ]) : static
Parameters
- $name : string
- $param : mixed
- $key : mixed = null
Return values
staticset()
Set a service. It will overwrite any previous service with the same name.
public
set(string $name, mixed $service) : static
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
- $name : string
- $service : mixed
Tags
Return values
staticsetCallable()
Set a service's callable string or object
public
setCallable(string $name, mixed $call) : static
Parameters
- $name : string
- $call : mixed
Return values
staticsetItems()
Set items
public
setItems(array<string|int, mixed> $items) : static
Parameters
- $items : array<string|int, mixed>
Return values
staticsetParameters()
Set a service's parameters
public
setParameters(string $name, mixed $params) : static
Parameters
- $name : string
- $params : mixed
Return values
staticsetServices()
Set service objects from an array of services
public
setServices(array<string|int, mixed> $services) : static
Parameters
- $services : array<string|int, mixed>