IContainer¶
-
interface
OCP\IContainer¶ - Class IContainerIContainer is the basic interface to be used for any internal dependency injection mechanism
Implemented by: OC\AppFramework\Utility\SimpleContainerSource: lib/public/IContainer.php#52 Parent: Psr\Container\ContainerInterface
Methods¶
-
public
OCP\IContainer::resolve($name)¶ Source: Parameters: - $name (string) the class name to resolve
Returns: \stdClassSince: 8.2.0
Deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get
Throws: \Psr\Container\ContainerExceptionInterfaceif the class could not be found or instantiatedThrows: \OCP\AppFramework\QueryExceptionif the class could not be found or instantiatedThrows: \Psr\Container\ContainerExceptionInterfaceif the class could not be found or instantiatedThrows: \OCP\AppFramework\QueryExceptionif the class could not be found or instantiated
-
public
OCP\IContainer::query($name, $autoload=true)¶ - Look up a service for a given name in the container.
Source: Parameters: - $name (string)
- $autoload (bool) Should we try to autoload the service. If we are trying to resolve built in types this makes no sense for example
Returns: mixed
Throws: \Psr\Container\ContainerExceptionInterfaceif the query could not be resolvedThrows: \OCP\AppFramework\QueryExceptionif the query could not be resolvedThrows: \Psr\Container\ContainerExceptionInterfaceif the query could not be resolvedThrows: \OCP\AppFramework\QueryExceptionif the query could not be resolvedSince: 6.0.0
Deprecated: 20.0.0 use \Psr\Container\ContainerInterface::get
-
public
OCP\IContainer::registerParameter($name, $value)¶ - A value is stored in the container with it’s corresponding name
Source: Parameters: - $name (string)
- $value (mixed)
Returns: void
Since: 6.0.0
Deprecated: 20.0.0 use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerParameter
-
public
OCP\IContainer::registerService($name, $closure, $shared=true)¶ - A service is registered in the container where a closure is passed in which will actuallycreate the service on demand.In case the parameter $shared is set to true (the default usage) the once created service will remain inmemory and be reused on subsequent calls.In case the parameter is false the service will be recreated on every call.
Source: Parameters: - $name (string)
- $closure (
Closure) - $shared (bool)
Returns: void
Since: 6.0.0
Deprecated: 20.0.0 use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerService
-
public
OCP\IContainer::registerAlias($alias, $target)¶ - 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 aninterface
Source: Parameters: - $alias (string) the alias that should be registered
- $target (string) the target that should be resolved instead
Since: 8.2.0
Deprecated: 20.0.0 use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerServiceAlias