Controller

class OCP\AppFramework\Controller
Base class to inherit your controllers from
Source:lib/public/AppFramework/Controller.php#46

Properties

protected static property OCP\AppFramework\Controller::$appName
app name
Source:lib/public/AppFramework/Controller.php#53
Type:string
Since:7.0.0
protected static property OCP\AppFramework\Controller::$request
current request
Source:lib/public/AppFramework/Controller.php#60
Type:\OCP\IRequest
Since:6.0.0

Methods

public OCP\AppFramework\Controller::__construct($appName, $request)
constructor of the controller
Source:

lib/public/AppFramework/Controller.php#74

Parameters:
  • $appName (string) the name of the app
  • $request (OCP\IRequest) an instance of the request
Since:

6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0

public OCP\AppFramework\Controller::getResponderByHTTPHeader($acceptHeader, $default=json)
Parses an HTTP accept header and returns the supported responder type
Source:

lib/public/AppFramework/Controller.php#118

Parameters:
  • $acceptHeader (string)
  • $default (string)
Returns:

string the responder type

Since:

7.0.0

Since:

7.0.0

protected OCP\AppFramework\Controller::registerResponder($format, $responder)
Registers a formatter for a type
Source:

lib/public/AppFramework/Controller.php#143

Parameters:
  • $format (string)
  • $responder (Closure)
Since:

7.0.0

public OCP\AppFramework\Controller::buildResponse($response, $format=json)
Serializes and formats a response
Source:

lib/public/AppFramework/Controller.php#157

Parameters:
  • $response (mixed) the value that was returned from a controller and

is not a Response instance * $format (string) the format for which a formatter has been registered

Throws:

\DomainException if format does not match a registered formatter

Returns:

\OCP\AppFramework\Http\Response

Since:

7.0.0