Nextcloud PHP API (stable18)

IAppContainer extends IContainer

Class IAppContainer

This container interface provides short cuts for app developers to access predefined app service.

Tags
since
6.0.0

Table of Contents

getAppName()  : string
used to return the appname of the set application
getServer()  : IServerContainer
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
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()  : stdClass
If a parameter is not registered in the container try to instantiate it by using reflection to find out how to build the class

Methods

getAppName()

used to return the appname of the set application

public getAppName() : string
Tags
since
6.0.0
Return values
string

the name of your application

query()

Look up a service for a given name in the container.

public query(string $name[, bool $autoload = true ]) : mixed
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
throws
QueryException

if the query could not be resolved

since
6.0.0
Return values
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) : mixed
Parameters
$alias : string

the alias that should be registered

$target : string

the target that should be resolved instead

Tags
since
8.2.0
Return values
mixed

registerCapability()

Register a capability

public registerCapability(string $serviceName) : mixed
Parameters
$serviceName : string

e.g. 'OCA\Files\Capabilities'

Tags
since
8.2.0
Return values
mixed

registerMiddleWare()

public registerMiddleWare(string $middleWare) : bool
Parameters
$middleWare : string
Tags
since
6.0.0
Return values
bool

registerParameter()

A value is stored in the container with it's corresponding name

public registerParameter(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed
Tags
since
6.0.0

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

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
since
6.0.0

resolve()

If a parameter is not registered in the container try to instantiate it by using reflection to find out how to build the class

public resolve(string $name) : stdClass
Parameters
$name : string

the class name to resolve

Tags
since
8.2.0
throws
QueryException

if the class could not be found or instantiated

Return values
stdClass

Search results