Properties

$_templatePath

$_templatePath : string|null

The subdirectory to the template.

Type

string|null

$_template

$_template : string|null

The template file to render.

Type

string|null

$_plugin

$_plugin : string|null|false

The plugin name to use.

Type

string|null|false

$_theme

$_theme : string|null|false

The theme name to use.

Type

string|null|false

$_layout

$_layout : string|null|false

The layout name to render.

Type

string|null|false

$_autoLayout

$_autoLayout : boolean|null

Whether or not autoLayout should be enabled.

Type

boolean|null

$_layoutPath

$_layoutPath : string|null

The layout path to build the view with.

Type

string|null

$_name

$_name : string|null

The view variables to use

Type

string|null

$_className

$_className : string|null

The view class name to use.

Can either use plugin notation, a short name or a fully namespaced classname.

Type

string|null

$_options

$_options : array

Additional options used when constructing the view.

This options array lets you provide custom constructor arguments to application/plugin view classes.

Type

array

$_helpers

$_helpers : array

The helpers to use

Type

array

$_vars

$_vars : array

View vars

Type

array

Methods

setVar()

setVar(string  $name, mixed  $value = null) : $this

Saves a variable for use inside a template.

Parameters

string $name

A string or an array of data.

mixed $value

Value.

Returns

$this

setVars()

setVars(array  $data, boolean  $merge = true) : $this

Saves view vars for use inside templates.

Parameters

array $data

Array of data.

boolean $merge

Whether to merge with existing vars, default true.

Returns

$this

hasVar()

hasVar(string  $name) : boolean

Check if view var is set.

Parameters

string $name

Var name

Returns

boolean

getVar()

getVar(string  $name) : mixed

Get view var

Parameters

string $name

Var name

Returns

mixed —

The var value or null if unset.

getVars()

getVars() : array

Get all view vars.

Returns

array

setTemplatePath()

setTemplatePath(string|null  $path) : $this

Sets path for template files.

Parameters

string|null $path

Path for view files.

Returns

$this

getTemplatePath()

getTemplatePath() : string|null

Gets path for template files.

Returns

string|null

templatePath()

templatePath(string|null  $path = null) : string|$this

Get/set path for template files.

Parameters

string|null $path

Path for view files. If null returns current path.

Returns

string|$this

setLayoutPath()

setLayoutPath(string|null  $path) : $this

Sets path for layout files.

Parameters

string|null $path

Path for layout files.

Returns

$this

getLayoutPath()

getLayoutPath() : string|null

Gets path for layout files.

Returns

string|null

layoutPath()

layoutPath(string|null  $path = null) : string|$this

Get/set path for layout files.

Parameters

string|null $path

Path for layout files. If null returns current path.

Returns

string|$this

enableAutoLayout()

enableAutoLayout(boolean  $enable = true) : $this

Turns on or off CakePHP's conventional mode of applying layout files.

On by default. Setting to off means that layouts will not be automatically applied to rendered views.

Parameters

boolean $enable

Boolean to turn on/off.

Returns

$this

disableAutoLayout()

disableAutoLayout() : $this

Turns off CakePHP's conventional mode of applying layout files.

Setting to off means that layouts will not be automatically applied to rendered views.

Returns

$this

isAutoLayoutEnabled()

isAutoLayoutEnabled() : boolean|null

Returns if CakePHP's conventional mode of applying layout files is enabled.

Disabled means that layouts will not be automatically applied to rendered views.

Returns

boolean|null

autoLayout()

autoLayout(boolean|null  $enable = null) : boolean|$this

Turns on or off CakePHP's conventional mode of applying layout files.

On by default. Setting to off means that layouts will not be automatically applied to rendered views.

Parameters

boolean|null $enable

Boolean to turn on/off. If null returns current value.

Returns

boolean|$this

setPlugin()

setPlugin(string|null|false  $name) : $this

Sets the plugin name to use.

False to remove current plugin name is deprecated as of 3.4.0. Use directly null instead.

Parameters

string|null|false $name

Plugin name. Use null or false to remove the current plugin name.

Returns

$this

getPlugin()

getPlugin() : string|null|false

Gets the plugin name to use.

Returns

string|null|false

plugin()

plugin(string|null|false  $name = null) : string|false|null|$this

The plugin name to use

Parameters

string|null|false $name

Plugin name. If null returns current plugin. Use false to remove the current plugin name.

Returns

string|false|null|$this

setHelpers()

setHelpers(array  $helpers, boolean  $merge = true) : $this

Sets the helpers to use.

Parameters

array $helpers

Helpers to use.

boolean $merge

Whether or not to merge existing data with the new data.

Returns

$this

getHelpers()

getHelpers() : array

Gets the helpers to use.

Returns

array

helpers()

helpers(array|null  $helpers = null, boolean  $merge = true) : array|$this

The helpers to use

Parameters

array|null $helpers

Helpers to use.

boolean $merge

Whether or not to merge existing data with the new data.

Returns

array|$this

setTheme()

setTheme(string|null|false  $theme) : $this

Sets the view theme to use.

False to remove current theme is deprecated as of 3.4.0. Use directly null instead.

Parameters

string|null|false $theme

Theme name. Use null or false to remove the current theme.

Returns

$this

getTheme()

getTheme() : string|null|false

Gets the view theme to use.

Returns

string|null|false

theme()

theme(string|null|false  $theme = null) : string|false|null|$this

The view theme to use.

Parameters

string|null|false $theme

Theme name. If null returns current theme. Use false to remove the current theme.

Returns

string|false|null|$this

setTemplate()

setTemplate(string|null  $name) : $this

Sets the name of the view file to render. The name specified is the filename in /src/Template/<SubFolder> without the .ctp extension.

Parameters

string|null $name

View file name to set.

Returns

$this

getTemplate()

getTemplate() : string|null

Gets the name of the view file to render. The name specified is the filename in /src/Template/<SubFolder> without the .ctp extension.

Returns

string|null

template()

template(string|null  $name = null) : string|$this

Get/set the name of the view file to render. The name specified is the filename in /src/Template/<SubFolder> without the .ctp extension.

Parameters

string|null $name

View file name to set. If null returns current name.

Returns

string|$this

setLayout()

setLayout(string|null|false  $name) : $this

Sets the name of the layout file to render the view inside of.

The name specified is the filename of the layout in /src/Template/Layout without the .ctp extension.

Parameters

string|null|false $name

Layout file name to set.

Returns

$this

getLayout()

getLayout() : string|null|false

Gets the name of the layout file to render the view inside of.

Returns

string|null|false

layout()

layout(string|null  $name = null) : string|$this

Get/set the name of the layout file to render the view inside of.

The name specified is the filename of the layout in /src/Template/Layout without the .ctp extension.

Parameters

string|null $name

Layout file name to set. If null returns current name.

Returns

string|$this

setOptions()

setOptions(array  $options, boolean  $merge = true) : $this

Sets additional options for the view.

This lets you provide custom constructor arguments to application/plugin view classes.

Parameters

array $options

An array of options.

boolean $merge

Whether or not to merge existing data with the new data.

Returns

$this

getOptions()

getOptions() : array

Gets additional options for the view.

Returns

array

options()

options(array|null  $options = null, boolean  $merge = true) : array|$this

Set additional options for the view.

This lets you provide custom constructor arguments to application/plugin view classes.

Parameters

array|null $options

Either an array of options or null to get current options.

boolean $merge

Whether or not to merge existing data with the new data.

Returns

array|$this

setName()

setName(string|null  $name) : $this

Sets the view name.

Parameters

string|null $name

The name of the view.

Returns

$this

getName()

getName() : string|null

Gets the view name.

Returns

string|null

name()

name(string|null  $name = null) : string|$this

Get/set the view name

Parameters

string|null $name

The name of the view

Returns

string|$this

setClassName()

setClassName(string|null  $name) : $this

Sets the view classname.

Accepts either a short name (Ajax) a plugin name (MyPlugin.Ajax) or a fully namespaced name (App\View\AppView) or null to use the View class provided by CakePHP.

Parameters

string|null $name

The class name for the view.

Returns

$this

getClassName()

getClassName() : string|null

Gets the view classname.

Returns

string|null

className()

className(string|null  $name = null) : string|$this

Get/set the view classname.

Accepts either a short name (Ajax) a plugin name (MyPlugin.Ajax) or a fully namespaced name (App\View\AppView).

Parameters

string|null $name

The class name for the view. Can be a plugin.class name reference, a short alias, or a fully namespaced name.

Returns

string|$this

build()

build(array  $vars = array(), \Cake\Http\ServerRequest|null  $request = null, \Cake\Http\Response|null  $response = null, \Cake\Event\EventManager|null  $events = null) : \Cake\View\View

Using the data in the builder, create a view instance.

If className() is null, App\View\AppView will be used. If that class does not exist, then Cake\View\View will be used.

Parameters

array $vars

The view variables/context to use.

\Cake\Http\ServerRequest|null $request

The request to use.

\Cake\Http\Response|null $response

The response to use.

\Cake\Event\EventManager|null $events

The event manager to use.

Throws

\Cake\View\Exception\MissingViewException

Returns

\Cake\View\View

jsonSerialize()

jsonSerialize() : array

Serializes the view builder object to a value that can be natively serialized and re-used to clone this builder instance.

Returns

array —

Serializable array of configuration properties.

createFromArray()

createFromArray(array  $config) : $this

Configures a view builder instance from serialized config.

Parameters

array $config

View builder configuration array.

Returns

$this —

Configured view builder instance.

serialize()

serialize() : string

Serializes the view builder object.

Returns

string

unserialize()

unserialize(string  $data) : $this

Unserializes the view builder object.

Parameters

string $data

Serialized string.

Returns

$this —

Configured view builder instance.