StandaloneTemplateResponse
extends TemplateResponse
in package
A template response that does not emit the loadAdditionalScripts events.
This is useful for pages that are authenticated but do not yet show the full nextcloud UI. Like the 2FA page, or the grant page in the login flow.
Tags
Table of Contents
Constants
- RENDER_AS_BASE = 'base'
- RENDER_AS_BLANK = ''
- RENDER_AS_ERROR = 'error'
- RENDER_AS_GUEST = 'guest'
- RENDER_AS_PUBLIC = 'public'
- RENDER_AS_USER = 'user'
Properties
- $appName : string
- app name
- $params : array<string|int, mixed>
- parameters
- $renderAs : string
- rendering type (admin, user, blank)
- $templateName : string
- name of the template
- $contentSecurityPolicy : ContentSecurityPolicy|null
- $cookies : array<string|int, mixed>
- Cookies that will be need to be constructed as header
- $ETag : string
- ETag
- $featurePolicy : FeaturePolicy
- $headers : H
- Headers
- $lastModified : DateTime
- Last modified date
- $status : S
- HTTP status code - defaults to STATUS OK
- $throttled : bool
- $throttleMetadata : array<string|int, mixed>
Methods
- __construct() : mixed
- constructor of TemplateResponse
- 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
- getApp() : string
- getContentSecurityPolicy() : EmptyContentSecurityPolicy|null
- Get the currently used Content-Security-Policy
- getCookies() : array<string|int, mixed>
- Returns the cookies
- getETag() : string
- Get the ETag
- getFeaturePolicy() : EmptyFeaturePolicy
- getHeaders() : mixed
- Returns the set headers
- getLastModified() : DateTime
- Get "last modified" date
- getParams() : array<string|int, mixed>
- Used for accessing the set parameters
- getRenderAs() : string
- Returns the set renderAs
- getStatus() : S
- Get response status
- getTemplateName() : string
- Used for accessing the name of the set template
- getThrottleMetadata() : array<string|int, mixed>
- 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
- setHeaders() : static
- Set the headers
- setLastModified() : Response
- Set "last modified" date
- setParams() : TemplateResponse
- Sets template parameters
- setStatus() : static
- Set response status
- throttle() : mixed
- Marks the response as to throttle. Will be throttled when the
Constants
RENDER_AS_BASE
public
mixed
RENDER_AS_BASE
= 'base'
Tags
RENDER_AS_BLANK
public
mixed
RENDER_AS_BLANK
= ''
Tags
RENDER_AS_ERROR
public
mixed
RENDER_AS_ERROR
= 'error'
Tags
RENDER_AS_GUEST
public
mixed
RENDER_AS_GUEST
= 'guest'
Tags
RENDER_AS_PUBLIC
public
mixed
RENDER_AS_PUBLIC
= 'public'
Tags
RENDER_AS_USER
public
mixed
RENDER_AS_USER
= 'user'
Tags
Properties
$appName
app name
protected
string
$appName
$params
parameters
protected
array<string|int, mixed>
$params
$renderAs
rendering type (admin, user, blank)
protected
string
$renderAs
$templateName
name of the template
protected
string
$templateName
$contentSecurityPolicy
private
ContentSecurityPolicy|null
$contentSecurityPolicy
= null
Used Content-Security-Policy
$cookies
Cookies that will be need to be constructed as header
private
array<string|int, mixed>
$cookies
= []
$ETag
ETag
private
string
$ETag
$featurePolicy
private
FeaturePolicy
$featurePolicy
$headers
Headers
private
H
$headers
$lastModified
Last modified date
private
DateTime
$lastModified
$status
HTTP status code - defaults to STATUS OK
private
S
$status
$throttled
private
bool
$throttled
= false
$throttleMetadata
private
array<string|int, mixed>
$throttleMetadata
= []
Methods
__construct()
constructor of TemplateResponse
public
__construct(string $appName, string $templateName[, array<string|int, mixed> $params = [] ][, string $renderAs = self::RENDER_AS_USER ][, S $status = Http::STATUS_OK ][, H $headers = [] ]) : mixed
Parameters
- $appName : string
-
the name of the app to load the template from
- $templateName : string
-
the name of the template
- $params : array<string|int, mixed> = []
-
an array of parameters which should be passed to the template
- $renderAs : string = self::RENDER_AS_USER
-
how the page should be rendered, defaults to user
- $status : S = Http::STATUS_OK
- $headers : H = []
Tags
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
Return values
$thisaddHeader()
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
Return values
$thiscacheFor()
Caches the response
public
cacheFor(int $cacheSeconds[, bool $public = false ][, bool $immutable = false ]) : $this
Parameters
- $cacheSeconds : int
-
amount of seconds the response is fresh, 0 to disable cache.
- $public : bool = false
-
whether the page should be cached by public proxy. Usually should be false, unless this is a static resources.
- $immutable : bool = false
-
whether browser should treat the resource as immutable and not ask the server for each page load if the resource changed.
Tags
Return values
$thisgetApp()
public
getApp() : string
Tags
Return values
string —the app id of the used template
getContentSecurityPolicy()
Get the currently used Content-Security-Policy
public
getContentSecurityPolicy() : EmptyContentSecurityPolicy|null
Tags
Return values
EmptyContentSecurityPolicy|null —Used Content-Security-Policy or null if none specified.
getCookies()
Returns the cookies
public
getCookies() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getETag()
Get the ETag
public
getETag() : string
Tags
Return values
string —the etag
getFeaturePolicy()
public
getFeaturePolicy() : EmptyFeaturePolicy
Tags
Return values
EmptyFeaturePolicygetHeaders()
Returns the set headers
public
getHeaders() : mixed
Tags
getLastModified()
Get "last modified" date
public
getLastModified() : DateTime
Tags
Return values
DateTime —RFC2822 formatted last modified date
getParams()
Used for accessing the set parameters
public
getParams() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —the params
getRenderAs()
Returns the set renderAs
public
getRenderAs() : string
Tags
Return values
string —the renderAs value
getStatus()
Get response status
public
getStatus() : S
Tags
Return values
SgetTemplateName()
Used for accessing the name of the set template
public
getTemplateName() : string
Tags
Return values
string —the name of the used template
getThrottleMetadata()
Returns the throttle metadata, defaults to empty array
public
getThrottleMetadata() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>invalidateCookie()
Invalidates the specified cookie
public
invalidateCookie(string $name) : $this
Parameters
- $name : string
Tags
Return values
$thisinvalidateCookies()
Invalidates the specified cookies
public
invalidateCookies(array<string|int, mixed> $cookieNames) : $this
Parameters
- $cookieNames : array<string|int, mixed>
-
array('foo', 'bar')
Tags
Return values
$thisisThrottled()
Whether the current response is throttled.
public
isThrottled() : mixed
Tags
render()
Returns the rendered html
public
render() : string
Tags
Return values
string —the rendered html
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
Return values
TemplateResponse —Reference to this object
setContentSecurityPolicy()
Set a Content-Security-Policy
public
setContentSecurityPolicy(EmptyContentSecurityPolicy $csp) : $this
Parameters
- $csp : EmptyContentSecurityPolicy
-
Policy to set for the response object
Tags
Return values
$thissetCookies()
Set the specified cookies
public
setCookies(array<string|int, mixed> $cookies) : $this
Parameters
- $cookies : array<string|int, mixed>
-
array('foo' => array('value' => 'bar', 'expire' => null))
Tags
Return values
$thissetETag()
Set the ETag
public
setETag(string $ETag) : Response
Parameters
- $ETag : string
Tags
Return values
Response —Reference to this object
setFeaturePolicy()
public
setFeaturePolicy(EmptyFeaturePolicy $featurePolicy) : self
Parameters
- $featurePolicy : EmptyFeaturePolicy
Tags
Return values
selfsetHeaders()
Set the headers
public
setHeaders(NewH $headers) : static
Parameters
- $headers : NewH
-
value header pairs
Tags
Return values
staticsetLastModified()
Set "last modified" date
public
setLastModified(DateTime $lastModified) : Response
Parameters
- $lastModified : DateTime
Tags
Return values
Response —Reference to this object
setParams()
Sets template parameters
public
setParams(array<string|int, mixed> $params) : TemplateResponse
Parameters
- $params : array<string|int, mixed>
-
an array with key => value structure which sets template variables
Tags
Return values
TemplateResponse —Reference to this object
setStatus()
Set response status
public
setStatus(NewS $status) : static
Parameters
- $status : NewS
-
a HTTP status code, see also the STATUS constants
Tags
Return values
staticthrottle()
Marks the response as to throttle. Will be throttled when the
public
throttle([array<string|int, mixed> $metadata = [] ]) : mixed
Parameters
- $metadata : array<string|int, mixed> = []