IAppContainer
extends
ContainerInterface, IContainer
in
This is a tagging interface for a container that belongs to an app
The interface currently extends IContainer, but this interface is deprecated as of Nextcloud 20, thus this interface won't extend it anymore once that was removed. So migrate to the ContainerInterface only.
Tags
Table of Contents
Methods
- get() : T : mixed)
- Finds an entry of the container by its identifier and returns it.
- getAppName() : string
- used to return the appname of the set application
- getServer() : ContainerInterface
- query() : T : mixed)
- Look up a service for a given name in the container.
- registerAlias() : void
- 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
- registerCapability() : mixed
- Register a capability
- registerMiddleWare() : bool
- 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() : T : mixed)
Methods
get()
Finds an entry of the container by its identifier and returns it.
public
get(T>|string $id) : T : mixed)
Parameters
- $id : T>|string
-
Identifier of the entry to look for.
Tags
Return values
T : mixed) —Entry.
getAppName()
used to return the appname of the set application
public
getAppName() : string
Tags
Return values
string —the name of your application
getServer()
public
getServer() : ContainerInterface
Tags
Return values
ContainerInterfacequery()
Look up a service for a given name in the container.
public
query(T>|string $name[, bool $autoload = true ]) : T : mixed)
use self::get()
Parameters
- $name : T>|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
Return values
T : mixed)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) : void
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
registerCapability()
Register a capability
public
registerCapability(string $serviceName) : mixed
use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerCapability
Parameters
- $serviceName : string
-
e.g. 'OCA\Files\Capabilities'
Tags
registerMiddleWare()
public
registerMiddleWare(string $middleWare) : bool
use \OCP\AppFramework\Bootstrap\IRegistrationContext::registerMiddleware
Parameters
- $middleWare : string
Tags
Return values
boolregisterParameter()
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, callable(IContainer): mixed $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 : callable(IContainer): mixed
- $shared : bool = true
Tags
resolve()
public
resolve(T>|string $name) : T : mixed)
use self::get()
Parameters
- $name : T>|string