Nextcloud PHP API (master)

IBootContext

Tags
since
20.0.0
Attributes
#[Consumable]
$since: '20.0.0'

Table of Contents

Methods

getAppContainer()  : ContainerInterface
Get hold of the app's container
getServerContainer()  : ContainerInterface
Get hold of the server DI container
injectFn()  : mixed|null
Invoke the given callable and inject all parameters based on their types and names

Methods

getAppContainer()

Get hold of the app's container

public getAppContainer() : ContainerInterface

Useful to register and query app-specific services

Tags
since
20.0.0
35.0.0

Typed as returning a ContainerInterface instead of the deprecated IAppContainer

Return values
ContainerInterface

getServerContainer()

Get hold of the server DI container

public getServerContainer() : ContainerInterface

Useful to register and query system-wide services

Tags
since
20.0.0
35.0.0

Typed as returning a ContainerInterface instead of the deprecated IServerContainer

Return values
ContainerInterface

injectFn()

Invoke the given callable and inject all parameters based on their types and names

public injectFn(callable $fn) : mixed|null

Note: when used with methods, make sure they are public or use \Closure::fromCallable to wrap the private method call, e.g.

  • $context->injectFn([$obj, 'publicMethod'])
  • $context->injectFn([$this, 'publicMethod'])
  • $context->injectFn(\Closure::fromCallable([$this, 'privateMethod']))

Note: the app container will be queried

Parameters
$fn : callable
Tags
throws
ContainerExceptionInterface

if at least one of the parameter can't be resolved

Throwable

any error the function invocation might cause

since
20.0.0
Return values
mixed|null

the return value of the invoked function, if any

On this page

Search results