Core Theme Components

Controller implements ServiceSubscriberInterface

The parent Controller class.

Tags
abstract

Interfaces, Classes and Traits

ServiceSubscriberInterface

Table of Contents

$container  : ContainerInterface
$response  : Response
getResponse()  : Response
Get the Response object used build the final response.
getSubscribedServices()  : array<string|int, mixed>
redirect()  : void
Redirect to a URL. Call the internal Wordpress function 'wp_safe_redirect'.
renderFile()  : BinaryFileResponse|null
Renders a file for download.
setContainer()  : ContainerInterface|null
render()  : Response|null
Renders the view as HTML and returns a Response object. Timber template caching parameters can be passed via the $kwargs argument.
renderJson()  : Response|null
Renders the view as JSON and returns a Response object.
addCorsHeaders()  : void
Add CORS headers to the headers array.
getQueuedHeaders()  : array<string|int, mixed>
Retrieves the headers set by Wordpress so that they can be into our Response object.

Properties

$container

protected ContainerInterface $container

Methods

getResponse()

Get the Response object used build the final response.

public getResponse() : Response
Return values
Response

getSubscribedServices()

public static getSubscribedServices() : array<string|int, mixed>
Return values
array<string|int, mixed>

redirect()

Redirect to a URL. Call the internal Wordpress function 'wp_safe_redirect'.

public redirect(string $url[, int $statusCode = 302 ]) : void
Parameters
$url : string
$statusCode : int = 302
Return values
void

renderFile()

Renders a file for download.

public renderFile(mixed $file[, string $filename = '' ][, string $contentDisposition = 'attachment' ]) : BinaryFileResponse|null
Parameters
$file : mixed
$filename : string = ''

Optional

$contentDisposition : string = 'attachment'

Optional, default is attachment.

Return values
BinaryFileResponse|null

setContainer()

public setContainer(ContainerInterface $container) : ContainerInterface|null
Parameters
$container : ContainerInterface
Tags
required
Return values
ContainerInterface|null

render()

Renders the view as HTML and returns a Response object. Timber template caching parameters can be passed via the $kwargs argument.

protected render(string $template, Context $context[, array<string|int, mixed> $kwargs = [] ]) : Response|null

kwargs: (string) cache_mode, (int) expires, (array) headers, (int) status_code

Parameters
$template : string
$context : Context
$kwargs : array<string|int, mixed> = []
Return values
Response|null

renderJson()

Renders the view as JSON and returns a Response object.

protected renderJson(array<string|int, mixed> $data, Context $context[, array<string|int, mixed> $kwargs = [] ]) : Response|null

kwargs: (int) json_encode_options, (array) headers, (int) status_code

Parameters
$data : array<string|int, mixed>
$context : Context
$kwargs : array<string|int, mixed> = []
Return values
Response|null

addCorsHeaders()

Add CORS headers to the headers array.

private addCorsHeaders(Request $request, array<string|int, mixed> &$headers) : void
Parameters
$request : Request
$headers : array<string|int, mixed>
Return values
void

getQueuedHeaders()

Retrieves the headers set by Wordpress so that they can be into our Response object.

private getQueuedHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results