PublicTemplateResponse extends TemplateResponse
Class PublicTemplateResponse
It handles headers, HTTP status code, last modified and ETag.
Tags
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
$appName
app name
    protected
        string
    $appName
    
    
    
$params
parameters
    protected
        array
    $params
    
    
    
$renderAs
rendering type (admin, user, blank)
    protected
        string
    $renderAs
    
    
    
$templateName
name of the template
    protected
        string
    $templateName
    
    
    
$contentSecurityPolicy
    private
        ContentSecurityPolicy|null
    $contentSecurityPolicy
     = null
    
    
$cookies
Cookies that will be need to be constructed as header
    private
        array
    $cookies
     = array()
    
    
$ETag
ETag
    private
        string
    $ETag
    
    
    
$featurePolicy
    private
        FeaturePolicy
    $featurePolicy
    
    
    
$footerVisible
    private
        mixed
    $footerVisible
     = true
    
    
$headerActions
    private
        mixed
    $headerActions
     = []
    
    
$headerDetails
    private
        mixed
    $headerDetails
     = ''
    
    
$headers
Headers - defaults to ['Cache-Control' => 'no-cache, no-store, must-revalidate']
    private
        array
    $headers
     = array('Cache-Control' => 'no-cache, no-store, must-revalidate')
    
    
$headerTitle
    private
        mixed
    $headerTitle
     = ''
    
    
$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 = array() ]) : mixed
    
        Parameters
- $appName : string
 - 
                    
the name of the app to load the template from
 - $templateName : string
 - 
                    
the name of the template
 - $params : array = array()
 - 
                    
an array of parameters which should be passed to the template
 
Tags
Return values
mixed —addCookie()
Adds a new cookie to the response
    public
                addCookie(string $name, string $value[, DateTime|null $expireDate = null ]) : $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.
 
Tags
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
Return values
$this —cacheFor()
Caches the response
    public
                cacheFor(int $cacheSeconds) : $this
    
        Parameters
- $cacheSeconds : int
 - 
                    
the amount of seconds that should be cached if 0 then caching will be disabled
 
Tags
Return values
$this —getActionCount()
    public
                getActionCount() : int
    
    
    
    Tags
Return values
int —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
    
    
    
    Tags
Return values
array —getETag()
Get the ETag
    public
                getETag() : string
    
    
    
    Tags
Return values
string —the etag
getFeaturePolicy()
    public
                getFeaturePolicy() : EmptyFeaturePolicy
    
    
    
    Tags
Return values
EmptyFeaturePolicy —getFooterVisible()
    public
                getFooterVisible() : bool
    
    
    
    Tags
Return values
bool —getHeaderDetails()
    public
                getHeaderDetails() : string
    
    
    
    Tags
Return values
string —getHeaders()
Returns the set headers
    public
                getHeaders() : array
    
    
    
    Tags
Return values
array —the headers
getHeaderTitle()
    public
                getHeaderTitle() : string
    
    
    
    Tags
Return values
string —getLastModified()
Get "last modified" date
    public
                getLastModified() : DateTime
    
    
    
    Tags
Return values
DateTime —RFC2822 formatted last modified date
getOtherActions()
    public
                getOtherActions() : \OCP\AppFramework\Http\Template\IMenuAction[]
    
    
    
    Tags
Return values
\OCP\AppFramework\Http\Template\IMenuAction[] —getParams()
Used for accessing the set parameters
    public
                getParams() : array
    
    
    
    Tags
Return values
array —the params
getPrimaryAction()
    public
                getPrimaryAction() : IMenuAction
    
    
    
    Tags
Return values
IMenuAction —getRenderAs()
Returns the set renderAs
    public
                getRenderAs() : string
    
    
    
    Tags
Return values
string —the renderAs value
getStatus()
Get response status
    public
                getStatus() : mixed
    
    
    
    Tags
Return values
mixed —getTemplateName()
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
    
    
    
    Tags
Return values
array —invalidateCookie()
Invalidates the specified cookie
    public
                invalidateCookie(string $name) : $this
    
        Parameters
- $name : string
 
Tags
Return values
$this —invalidateCookies()
Invalidates the specified cookies
    public
                invalidateCookies(array $cookieNames) : $this
    
        Parameters
- $cookieNames : array
 - 
                    
array('foo', 'bar')
 
Tags
Return values
$this —isThrottled()
Whether the current response is throttled.
    public
                isThrottled() : mixed
    
    
    
    Tags
Return values
mixed —render()
Returns the rendered html
    public
                render() : string
    
    
    
    Tags
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
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
$this —setCookies()
Set the specified cookies
    public
                setCookies(array $cookies) : $this
    
        Parameters
- $cookies : array
 - 
                    
array('foo' => array('value' => 'bar', 'expire' => null))
 
Tags
Return values
$this —setETag()
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
self —setFooterVisible()
    public
                setFooterVisible([bool $visible = false ]) : mixed
    
        Parameters
- $visible : bool = false
 
Tags
Return values
mixed —setHeaderActions()
    public
                setHeaderActions(array $actions) : mixed
    
        Parameters
- $actions : array
 
Tags
Return values
mixed —setHeaderDetails()
    public
                setHeaderDetails(string $details) : mixed
    
        Parameters
- $details : string
 
Tags
Return values
mixed —setHeaders()
Set the headers
    public
                setHeaders(array $headers) : $this
    
        Parameters
- $headers : array
 - 
                    
value header pairs
 
Tags
Return values
$this —setHeaderTitle()
    public
                setHeaderTitle(string $title) : mixed
    
        Parameters
- $title : string
 
Tags
Return values
mixed —setLastModified()
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 $params) : TemplateResponse
    
        Parameters
- $params : array
 - 
                    
an array with key => value structure which sets template variables
 
Tags
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
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 = []