Nextcloud PHP API (stable19)

PublicTemplateResponse extends TemplateResponse

Class PublicTemplateResponse

It handles headers, HTTP status code, last modified and ETag.

Tags
since
14.0.0

Table of Contents

EVENT_LOAD_ADDITIONAL_SCRIPTS  = self::class . '::loadAdditionalScripts'
EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN  = self::class . '::loadAdditionalScriptsLoggedIn'
$appName  : string
app name
$params  : array
parameters
$renderAs  : string
rendering type (admin, user, blank)
$templateName  : string
name of the template
$contentSecurityPolicy  : ContentSecurityPolicy|null
$cookies  : array
Cookies that will be need to be constructed as header
$ETag  : string
ETag
$featurePolicy  : FeaturePolicy
$footerVisible  : mixed
$headerActions  : mixed
$headerDetails  : mixed
$headers  : array
Headers - defaults to ['Cache-Control' => 'no-cache, no-store, must-revalidate']
$headerTitle  : mixed
$lastModified  : DateTime
Last modified date
$status  : int
HTTP status code - defaults to STATUS OK
$throttled  : bool
$throttleMetadata  : array
__construct()  : mixed
PublicTemplateResponse constructor.
addCookie()  : $this
Adds a new cookie to the response
addHeader()  : $this
Adds a new header to the response that will be called before the render function
cacheFor()  : $this
Caches the response
getActionCount()  : int
getContentSecurityPolicy()  : EmptyContentSecurityPolicy|null
Get the currently used Content-Security-Policy
getCookies()  : array
Returns the cookies
getETag()  : string
Get the ETag
getFeaturePolicy()  : EmptyFeaturePolicy
getFooterVisible()  : bool
getHeaderDetails()  : string
getHeaders()  : array
Returns the set headers
getHeaderTitle()  : string
getLastModified()  : DateTime
Get "last modified" date
getOtherActions()  : \OCP\AppFramework\Http\Template\IMenuAction[]
getParams()  : array
Used for accessing the set parameters
getPrimaryAction()  : IMenuAction
getRenderAs()  : string
Returns the set renderAs
getStatus()  : mixed
Get response status
getTemplateName()  : string
Used for accessing the name of the set template
getThrottleMetadata()  : array
Returns the throttle metadata, defaults to empty array
invalidateCookie()  : $this
Invalidates the specified cookie
invalidateCookies()  : $this
Invalidates the specified cookies
isThrottled()  : mixed
Whether the current response is throttled.
render()  : string
Returns the rendered html
renderAs()  : TemplateResponse
Sets the template page
setContentSecurityPolicy()  : $this
Set a Content-Security-Policy
setCookies()  : $this
Set the specified cookies
setETag()  : Response
Set the ETag
setFeaturePolicy()  : self
setFooterVisible()  : mixed
setHeaderActions()  : mixed
setHeaderDetails()  : mixed
setHeaders()  : $this
Set the headers
setHeaderTitle()  : mixed
setLastModified()  : Response
Set "last modified" date
setParams()  : TemplateResponse
Sets template parameters
setStatus()  : Response
Set response status
throttle()  : mixed
Marks the response as to throttle. Will be throttled when the

Constants

EVENT_LOAD_ADDITIONAL_SCRIPTS

public mixed EVENT_LOAD_ADDITIONAL_SCRIPTS = self::class . '::loadAdditionalScripts'

EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN

public mixed EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN = self::class . '::loadAdditionalScriptsLoggedIn'

Properties

$renderAs

rendering type (admin, user, blank)

protected string $renderAs

$cookies

Cookies that will be need to be constructed as header

private array $cookies = []

$headers

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

private array $headers = ['Cache-Control' => 'no-cache, no-store, must-revalidate']

$lastModified

Last modified date

private DateTime $lastModified

$status

HTTP status code - defaults to STATUS OK

private int $status = OCPAppFrameworkHttp::STATUS_OK

$throttled

private bool $throttled = false

$throttleMetadata

private array $throttleMetadata = []

Methods

__construct()

PublicTemplateResponse constructor.

public __construct(string $appName, string $templateName[, array $params = [] ]) : mixed
Parameters
$appName : string

the name of the app to load the template from

$templateName : string

the name of the template

$params : array = []

an array of parameters which should be passed to the template

Tags
since
14.0.0
Return values
mixed

addCookie()

Adds a new cookie to the response

public addCookie(string $name, string $value[, DateTime|null $expireDate = null ][, string $sameSite = 'Lax' ]) : $this
Parameters
$name : string

The name of the cookie

$value : string

The value of the cookie

$expireDate : DateTime|null = null

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

$sameSite : string = 'Lax'

The samesite value of the cookie. Defaults to Lax. Other possibilities are Strict or None

Tags
since
8.0.0
Return values
$this

addHeader()

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

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

The name of the HTTP header

$value : string

The value, null will delete it

Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
$this

cacheFor()

Caches the response

public cacheFor(int $cacheSeconds[, bool $public = false ]) : $this
Parameters
$cacheSeconds : int

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

$public : bool = false
Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
$this

getCookies()

Returns the cookies

public getCookies() : array
Tags
since
8.0.0
Return values
array

getETag()

Get the ETag

public getETag() : string
Tags
since
6.0.0
Return values
string

the etag

getHeaderDetails()

public getHeaderDetails() : string
Tags
since
14.0.0
Return values
string

getHeaders()

Returns the set headers

public getHeaders() : array
Tags
since
6.0.0
Return values
array

the headers

getLastModified()

Get "last modified" date

public getLastModified() : DateTime
Tags
since
6.0.0
Return values
DateTime

RFC2822 formatted last modified date

getOtherActions()

public getOtherActions() : \OCP\AppFramework\Http\Template\IMenuAction[]
Tags
since
14.0.0
Return values
\OCP\AppFramework\Http\Template\IMenuAction[]

getParams()

Used for accessing the set parameters

public getParams() : array
Tags
since
6.0.0
Return values
array

the params

getRenderAs()

Returns the set renderAs

public getRenderAs() : string
Tags
since
6.0.0
Return values
string

the renderAs value

getStatus()

Get response status

public getStatus() : mixed
Tags
since
6.0.0
Return values
mixed

getTemplateName()

Used for accessing the name of the set template

public getTemplateName() : string
Tags
since
6.0.0
Return values
string

the name of the used template

getThrottleMetadata()

Returns the throttle metadata, defaults to empty array

public getThrottleMetadata() : array
Tags
since
13.0.0
Return values
array

invalidateCookie()

Invalidates the specified cookie

public invalidateCookie(string $name) : $this
Parameters
$name : string
Tags
since
8.0.0
Return values
$this

invalidateCookies()

Invalidates the specified cookies

public invalidateCookies(array $cookieNames) : $this
Parameters
$cookieNames : array

array('foo', 'bar')

Tags
since
8.0.0
Return values
$this

isThrottled()

Whether the current response is throttled.

public isThrottled() : mixed
Tags
since
12.0.0
Return values
mixed

render()

Returns the rendered html

public render() : string
Tags
since
14.0.0
Return values
string

renderAs()

Sets the template page

public renderAs(string $renderAs) : TemplateResponse
Parameters
$renderAs : string

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

Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
TemplateResponse

Reference to this object

setCookies()

Set the specified cookies

public setCookies(array $cookies) : $this
Parameters
$cookies : array

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

Tags
since
8.0.0
Return values
$this

setETag()

Set the ETag

public setETag(string $ETag) : Response
Parameters
$ETag : string
Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
Response

Reference to this object

setFooterVisible()

public setFooterVisible([bool $visible = false ]) : mixed
Parameters
$visible : bool = false
Tags
since
14.0.0
Return values
mixed

setHeaderActions()

public setHeaderActions(array $actions) : mixed
Parameters
$actions : array
Tags
since
14.0.0
throws
InvalidArgumentException
Return values
mixed

setHeaderDetails()

public setHeaderDetails(string $details) : mixed
Parameters
$details : string
Tags
since
14.0.0
Return values
mixed

setHeaders()

Set the headers

public setHeaders(array $headers) : $this
Parameters
$headers : array

value header pairs

Tags
since
8.0.0
Return values
$this

setHeaderTitle()

public setHeaderTitle(string $title) : mixed
Parameters
$title : string
Tags
since
14.0.0
Return values
mixed

setLastModified()

Set "last modified" date

public setLastModified(DateTime $lastModified) : Response
Parameters
$lastModified : DateTime
Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
Response

Reference to this object

setParams()

Sets template parameters

public setParams(array $params) : TemplateResponse
Parameters
$params : array

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

Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
TemplateResponse

Reference to this object

setStatus()

Set response status

public setStatus(int $status) : Response
Parameters
$status : int

a HTTP status code, see also the STATUS constants

Tags
since
6.0.0
  • return value was added in 7.0.0
Return values
Response

Reference to this object

throttle()

Marks the response as to throttle. Will be throttled when the

public throttle([array $metadata = [] ]) : mixed
Parameters
$metadata : array = []
Tags
BruteForceProtection

annotation is added.

since
12.0.0
Return values
mixed

Search results