Nextcloud PHP API (stable18)

Controller

Base class to inherit your controllers from

Tags
since
6.0.0

Table of Contents

$appName  : string
app name
$request  : IRequest
current request
$responders  : array
__construct()  : mixed
constructor of the controller
buildResponse()  : Response
Serializes and formats a response
getResponderByHTTPHeader()  : string
Parses an HTTP accept header and returns the supported responder type
registerResponder()  : mixed
Registers a formatter for a type

Properties

$appName

app name

protected string $appName
Tags
since
7.0.0

$responders

private array $responders
Tags
since
7.0.0

Methods

__construct()

constructor of the controller

public __construct(string $appName, IRequest $request) : mixed
Parameters
$appName : string

the name of the app

$request : IRequest

an instance of the request

Tags
since
6.0.0
  • parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
Return values
mixed

buildResponse()

Serializes and formats a response

public buildResponse(mixed $response[, string $format = 'json' ]) : Response
Parameters
$response : mixed

the value that was returned from a controller and is not a Response instance

$format : string = 'json'

the format for which a formatter has been registered

Tags
throws
DomainException

if format does not match a registered formatter

since
7.0.0
Return values
Response

getResponderByHTTPHeader()

Parses an HTTP accept header and returns the supported responder type

public getResponderByHTTPHeader(string $acceptHeader[, string $default = 'json' ]) : string
Parameters
$acceptHeader : string
$default : string = 'json'
Tags
since
7.0.0
since
9.1.0

Added default parameter

Return values
string

the responder type

registerResponder()

Registers a formatter for a type

protected registerResponder(string $format, Closure $responder) : mixed
Parameters
$format : string
$responder : Closure
Tags
since
7.0.0
Return values
mixed

Search results