PHP Class Pop\Service\Locator

Author: Nick Sagona, III ([email protected])
Exibir arquivo Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$loaded array Services that are loaded (instantiated)
$services array Services

Public Methods

Method Description
__construct ( array $services = null ) : Locator Constructor
get ( string $name ) : mixed Get a service object.
remove ( string $name ) : Locator Remove a service
set ( string $name, mixed $call, mixed $params = null ) : Locator Set a service object. It will overwrite any previous service with the same name.

Protected Methods

Method Description
load ( string $name ) : Locator Load a service object. It will overwrite any previous service with the same name.

Method Details

__construct() public method

Instantiate the service locator object. The optional $services parameter can contain a closure or an array of call/param keys that define what to call when the service is needed. Valid examples are ('params' are optional): $services = array( 'service1' => function($locator) {...}, 'service2' => array( 'call' => 'SomeClass', 'params' => array(...) ), 'service3' => array( 'call' => 'SomeClass', 'params' => function() {...} ) );
public __construct ( array $services = null ) : Locator
$services array
return Locator

get() public method

Get a service object.
public get ( string $name ) : mixed
$name string
return mixed

load() protected method

Load a service object. It will overwrite any previous service with the same name.
protected load ( string $name ) : Locator
$name string
return Locator

remove() public method

Remove a service
public remove ( string $name ) : Locator
$name string
return Locator

set() public method

Set a service object. It will overwrite any previous service with the same name.
public set ( string $name, mixed $call, mixed $params = null ) : Locator
$name string
$call mixed
$params mixed
return Locator

Property Details

$loaded protected_oe property

Services that are loaded (instantiated)
protected array $loaded
return array

$services protected_oe property

Services
protected array $services
return array