Documentation

Locator
in package
implements ArrayAccess, Countable, IteratorAggregate

Service locator class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
4.2.0

Table of Contents

Interfaces

ArrayAccess
Countable
IteratorAggregate

Properties

$loaded  : array<string|int, mixed>
Services that are loaded/instantiated
$services  : array<string|int, mixed>
Services
$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
addParam()  : static
Add to a service's parameters
count()  : int
Return count
get()  : mixed
Get/load a service
getCall()  : mixed
Get a service's callable string or object
getIterator()  : ArrayIterator
Get iterator
getParams()  : mixed
Get a service's parameters
hasParams()  : 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
removeParam()  : static
Remove a service's parameters
set()  : static
Set a service. It will overwrite any previous service with the same name.
setCall()  : static
Set a service's callable string or object
setParams()  : static
Set a service's parameters
setServices()  : static
Set service objects from an array of services

Properties

$loaded

Services that are loaded/instantiated

protected array<string|int, mixed> $loaded = []

$services

Services

protected array<string|int, mixed> $services = []

$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
throws
Exception

__get()

Get a service

public __get(string $name) : mixed
Parameters
$name : string
Tags
throws
Exception

__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
throws
Exception

__unset()

Unset a service

public __unset(string $name) : void
Parameters
$name : string

addParam()

Add to a service's parameters

public addParam(string $name, mixed $param[, mixed $key = null ]) : static
Parameters
$name : string
$param : mixed
$key : mixed = null
Return values
static

count()

Return count

public count() : int
Return values
int

get()

Get/load a service

public get(string $name) : mixed
Parameters
$name : string
Tags
throws
Exception

getCall()

Get a service's callable string or object

public getCall(string $name) : mixed
Parameters
$name : string

getIterator()

Get iterator

public getIterator() : ArrayIterator
Return values
ArrayIterator

getParams()

Get a service's parameters

public getParams(string $name) : mixed
Parameters
$name : string

hasParams()

Check if a service has parameters

public hasParams(string $name) : bool
Parameters
$name : string
Return values
bool

isAvailable()

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

public isAvailable(string $name) : bool
Parameters
$name : string
Return values
bool

isLoaded()

Determine of a service object is loaded

public isLoaded(string $name) : bool
Parameters
$name : string
Return values
bool

offsetExists()

Determine if a service is available

public offsetExists(mixed $offset) : bool
Parameters
$offset : mixed
Return values
bool

offsetGet()

Get a service

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Tags
throws
Exception

offsetSet()

Set a service

public offsetSet(mixed $offset, mixed $value) : void
Parameters
$offset : mixed
$value : mixed
Tags
throws
Exception

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
static

removeParam()

Remove a service's parameters

public removeParam(string $name, mixed $param[, mixed $key = null ]) : static
Parameters
$name : string
$param : mixed
$key : mixed = null
Return values
static

set()

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
throws
Exception
Return values
static

setCall()

Set a service's callable string or object

public setCall(string $name, mixed $call) : static
Parameters
$name : string
$call : mixed
Return values
static

setParams()

Set a service's parameters

public setParams(string $name, mixed $params) : static
Parameters
$name : string
$params : mixed
Return values
static

setServices()

Set service objects from an array of services

public setServices(array<string|int, mixed> $services) : static
Parameters
$services : array<string|int, mixed>
Tags
throws
Exception
Return values
static

        
On this page

Search results