class ServiceContainer implements ServiceContainerInterface
A simple service container with constructors
Methods
$this |
init(array $initial_services = array(), array $services_providers = array(), array $services_protected = array())
Initialize the service container system |
|
$this |
setProvider(string $name, array $provider)
Define a service constructor like |
|
mixed |
getProvider(string $name)
Get a service constructor if it exists |
|
bool |
hasProvider(string $name)
Test if a constructor exists for a service |
|
$this |
setProtected(string $name)
Define a service as protected |
|
bool |
isProtected(string $name)
Test if a service is protected |
|
$this |
setService(string $name, object|callable $callback, bool $protected = false)
Register a new service called |
|
mixed |
getService(string $name, array $arguments = array(), int $failure = self::FAIL_WITH_ERROR)
Get a service called |
|
mixed |
hasService(string $name)
Test if a service exists in the container |
|
mixed |
unsetService(string $name)
Unset a service if it is not protected |
Details
at line 73
public $this
init(array $initial_services = array(), array $services_providers = array(), array $services_protected = array())
Initialize the service container system
at line 111
public $this
setProvider(string $name, array $provider)
Define a service constructor like array( name , callback , protected )
or a closure
at line 126
public mixed
getProvider(string $name)
Get a service constructor if it exists
at line 138
public bool
hasProvider(string $name)
Test if a constructor exists for a service
at line 149
public $this
setProtected(string $name)
Define a service as protected
at line 161
public bool
isProtected(string $name)
Test if a service is protected
at line 178
public $this
setService(string $name, object|callable $callback, bool $protected = false)
Register a new service called $name
declared as NOT protected by default
at line 203
public 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 227
public mixed
hasService(string $name)
Test if a service exists in the container
at line 239
public mixed
unsetService(string $name)
Unset a service if it is not protected