ServiceContainer
class ServiceContainer implements ServiceContainerInterface
A simple service container with constructors
Traits
Methods
Initialize the service container system
Define a service constructor like array( name , callback , protected )
or a closure
Get a service constructor if it exists
Test if a constructor exists for a service
Define a service as protected
Test if a service is protected
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
Test if a service exists in the container
Unset a service if it is not protected
Details
at line 75
$this
init(
array $initial_services = array(),
array $services_providers = array(),
array $services_protected = array())
Initialize the service container system
at line 113
mixed
setProvider(
string $name,
array $provider)
Define a service constructor like array( name , callback , protected )
or a closure
at line 128
mixed
getProvider(
string $name)
Get a service constructor if it exists
at line 140
bool
hasProvider(
string $name)
Test if a constructor exists for a service
at line 151
$this
setProtected(
string $name)
Define a service as protected
at line 163
bool
isProtected(
string $name)
Test if a service is protected
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
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
at line 229
mixed
hasService(
string $name)
Test if a service exists in the container
at line 241
mixed
unsetService(
string $name)
Unset a service if it is not protected