IContainer
extends
ContainerInterface
in
Class IContainer
use \Psr\Container\ContainerInterface
IContainer is the basic interface to be used for any internal dependency injection mechanism
Tags
Table of Contents
Methods
- query() : mixed
- Look up a service for a given name in the container.
- registerAlias() : mixed
- Shortcut for returning a service from a service under a different key, e.g. to tell the container to return a class when queried for an interface
- registerParameter() : void
- A value is stored in the container with it's corresponding name
- registerService() : void
- A service is registered in the container where a closure is passed in which will actually create the service on demand.
- resolve() : stdClass
Methods
query()
Look up a service for a given name in the container.
public
query(string $name[, bool $autoload = true ]) : mixed
use \Psr\Container\ContainerInterface::get
Parameters
- $name : string
- $autoload : bool = true
-
Should we try to autoload the service. If we are trying to resolve built in types this makes no sense for example
Tags
registerAlias()
Shortcut for returning a service from a service under a different key, e.g. to tell the container to return a class when queried for an interface
public
registerAlias(string $alias, string $target) : mixed
use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerServiceAlias
Parameters
- $alias : string
-
the alias that should be registered
- $target : string
-
the target that should be resolved instead
Tags
registerParameter()
A value is stored in the container with it's corresponding name
public
registerParameter(string $name, mixed $value) : void
use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerParameter
Parameters
- $name : string
- $value : mixed
Tags
registerService()
A service is registered in the container where a closure is passed in which will actually create the service on demand.
public
registerService(string $name, Closure $closure[, bool $shared = true ]) : void
use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerService
In case the parameter $shared is set to true (the default usage) the once created service will remain in memory and be reused on subsequent calls. In case the parameter is false the service will be recreated on every call.
Parameters
- $name : string
- $closure : Closure
- $shared : bool = true
Tags
resolve()
public
resolve(string $name) : stdClass
use \Psr\Container\ContainerInterface::get
Parameters
- $name : string
-
the class name to resolve