ApiServiceContainer
class ApiServiceContainer extends ServiceContainer
A service container with constructors based on an API declaration and validation
Traits
Methods
Initialize the service container system
Define a service constructor like array( name , callback , protected )
or a closure
Register a new service called $name
declared as NOT protected by default
Get a service called $name
throwing an error by default if it does not exist yet and can not be created
Usage:
Details
in
ServiceContainer at line 75
$this
init(
array $initial_services = array(),
array $services_providers = array(),
array $services_protected = array())
Initialize the service container system
in
ServiceContainer at line 113
mixed
setProvider(
string $name,
array $provider)
Define a service constructor like array( name , callback , protected )
or a closure
in
ServiceContainer at line 128
mixed
getProvider(
string $name)
Get a service constructor if it exists
in
ServiceContainer at line 140
bool
hasProvider(
string $name)
Test if a constructor exists for a service
in
ServiceContainer at line 151
$this
setProtected(
string $name)
Define a service as protected
in
ServiceContainer at line 163
bool
isProtected(
string $name)
Test if a service is protected
in
ServiceContainer at line 180
mixed
setService(
string $name,
object|callable $callback,
bool $protected = false)
Register a new service called $name
declared as NOT protected by default
in
ServiceContainer at line 205
mixed
getService(
string $name,
array $arguments = array(),
int $failure = self::FAIL_WITH_ERROR)
Get a service called $name
throwing an error by default if it does not exist yet and can not be created
in
ServiceContainer at line 229
mixed
hasService(
string $name)
Test if a service exists in the container
in
ServiceContainer at line 241
mixed
unsetService(
string $name)
Unset a service if it is not protected
at line 56
static
object
apiFactory(
string $name,
string $class,
array $arguments = array())
Usage:
self::set($var, self::apiFactory($var, $val));