Properties

$templateName

$templateName : string

name of the template

Type

string

$params

$params : array

parameters

Type

array

$renderAs

$renderAs : string

rendering type (admin, user, blank)

Type

string

$appName

$appName : string

app name

Type

string

$headers

$headers : array

Headers - defaults to ['Cache-Control' => 'no-cache, must-revalidate']

Type

array

$cookies

$cookies : array

Cookies that will be need to be constructed as header

Type

array

$status

$status : integer

HTTP status code - defaults to STATUS OK

Type

integer

$lastModified

$lastModified : \DateTime

Last modified date

Type

\DateTime

$ETag

$ETag : string

ETag

Type

string

Methods

cacheFor()

cacheFor(integer  $cacheSeconds) : $this

Caches the response

Parameters

integer $cacheSeconds

the amount of seconds that should be cached if 0 then caching will be disabled

Returns

$this

addCookie()

addCookie(string  $name, string  $value, \DateTime|null  $expireDate = null) : $this

Adds a new cookie to the response

Parameters

string $name

The name of the cookie

string $value

The value of the cookie

\DateTime|null $expireDate

Date on that the cookie should expire, if set to null cookie will be considered as session cookie.

Returns

$this

setCookies()

setCookies(array  $cookies) : $this

Set the specified cookies

Parameters

array $cookies

array('foo' => array('value' => 'bar', 'expire' => null))

Returns

$this

invalidateCookie()

invalidateCookie(string  $name) : $this

Invalidates the specified cookie

Parameters

string $name

Returns

$this

invalidateCookies()

invalidateCookies(array  $cookieNames) : $this

Invalidates the specified cookies

Parameters

array $cookieNames

array('foo', 'bar')

Returns

$this

getCookies()

getCookies() : array

Returns the cookies

Returns

array

addHeader()

addHeader(string  $name, string  $value) : $this

Adds a new header to the response that will be called before the render function

Parameters

string $name

The name of the HTTP header

string $value

The value, null will delete it

Returns

$this

setHeaders()

setHeaders(array  $headers) : $this

Set the headers

Parameters

array $headers

value header pairs

Returns

$this

getHeaders()

getHeaders() : array

Returns the set headers

Returns

array —

the headers

render()

render() : string

Returns the rendered html

Returns

string —

the rendered html

setStatus()

setStatus(integer  $status) : \OCP\AppFramework\Http\Response

Set response status

Parameters

integer $status

a HTTP status code, see also the STATUS constants

Returns

\OCP\AppFramework\Http\Response

Reference to this object

setContentSecurityPolicy()

setContentSecurityPolicy(\OCP\AppFramework\Http\ContentSecurityPolicy  $csp) : $this

Set a Content-Security-Policy

Parameters

\OCP\AppFramework\Http\ContentSecurityPolicy $csp

Policy to set for the response object

Returns

$this

getContentSecurityPolicy()

getContentSecurityPolicy() : \OCP\AppFramework\Http\ContentSecurityPolicy|null

Get the currently used Content-Security-Policy

Returns

\OCP\AppFramework\Http\ContentSecurityPolicy|null —

Used Content-Security-Policy or null if none specified.

getStatus()

getStatus() 

Get response status

getETag()

getETag() : string

Get the ETag

Returns

string —

the etag

getLastModified()

getLastModified() : \DateTime

Get "last modified" date

Returns

\DateTime —

RFC2822 formatted last modified date

setETag()

setETag(string  $ETag) : \OCP\AppFramework\Http\Response

Set the ETag

Parameters

string $ETag

Returns

\OCP\AppFramework\Http\Response

Reference to this object

setLastModified()

setLastModified(\DateTime  $lastModified) : \OCP\AppFramework\Http\Response

Set "last modified" date

Parameters

\DateTime $lastModified

Returns

\OCP\AppFramework\Http\Response

Reference to this object

__construct()

__construct(string  $appName, string  $templateName, array  $params = array(), string  $renderAs = 'user') 

constructor of TemplateResponse

Parameters

string $appName

the name of the app to load the template from

string $templateName

the name of the template

array $params

an array of parameters which should be passed to the template

string $renderAs

how the page should be rendered, defaults to user

setParams()

setParams(array  $params) : \OCP\AppFramework\Http\TemplateResponse

Sets template parameters

Parameters

array $params

an array with key => value structure which sets template variables

Returns

\OCP\AppFramework\Http\TemplateResponse

Reference to this object

getParams()

getParams() : array

Used for accessing the set parameters

Returns

array —

the params

getTemplateName()

getTemplateName() : string

Used for accessing the name of the set template

Returns

string —

the name of the used template

renderAs()

renderAs(string  $renderAs) : \OCP\AppFramework\Http\TemplateResponse

Sets the template page

Parameters

string $renderAs

admin, user or blank. Admin also prints the admin settings header and footer, user renders the normal normal page including footer and header and blank just renders the plain template

Returns

\OCP\AppFramework\Http\TemplateResponse

Reference to this object

getRenderAs()

getRenderAs() : string

Returns the set renderAs

Returns

string —

the renderAs value