Nextcloud PHP API (master)

IServerContainer extends ContainerInterface, IContainer

This is a tagging interface for the server container

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

Table of Contents

Methods

get()  : T : mixed)
Finds an entry of the container by its identifier and returns it.
getL10N()  : IL10N
get an L10N instance
getUserFolder()  : Folder|null
Returns a view to ownCloud's files folder
getWebRoot()  : string
Get the webroot
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
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
template
throws
NotFoundExceptionInterface

No entry was found for this identifier.

throws
ContainerExceptionInterface

Error while retrieving the entry.

since
34.0.0
Return values
T : mixed)

Entry.

getL10N()

get an L10N instance

public getL10N(string $app[, string $lang = null ]) : IL10N

have it injected or fetch it through \Psr\Container\ContainerInterface::get

Parameters
$app : string

appid

$lang : string = null
Tags
since
6.0.0
  • parameter $lang was added in 8.0.0
Return values
IL10N

getUserFolder()

Returns a view to ownCloud's files folder

public getUserFolder([string $userId = null ]) : Folder|null

have it injected or fetch it through \Psr\Container\ContainerInterface::get

Parameters
$userId : string = null

user ID

Tags
since
6.0.0
  • parameter $userId was added in 8.0.0
see
getUserFolder

in \OCP\Files\IRootFolder

Return values
Folder|null

getWebRoot()

Get the webroot

public getWebRoot() : string

have it injected or fetch it through \Psr\Container\ContainerInterface::get

Tags
since
8.0.0
Return values
string

query()

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
template
throws
ContainerExceptionInterface

if the query could not be resolved

throws
NotFoundExceptionInterface

if the name could not be found within the container

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

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

resolve()

public resolve(T>|string $name) : T : mixed)

use self::get()

Parameters
$name : T>|string
Tags
template

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

since
8.2.0
throws
ContainerExceptionInterface

if the class could not be found or instantiated

Return values
T : mixed)

        
On this page

Search results