Trait ViewVarsTrait

Provides the set() method for collecting template context.

Once collected context data can be passed to another object. This is done in Controller, TemplateTask and View for example.

Direct Known Users

Cake\Controller\Controller, Cake\Mailer\Email, Cake\View\Cell, Cake\View\View

Indirect Known Users

Cake\Controller\ErrorController, Cake\View\AjaxView, Cake\View\JsonView, Cake\View\SerializedView, Cake\View\XmlView
Namespace: Cake\View
Located at View/ViewVarsTrait.php

Method Detail

createViewsource public

createView( string|null $viewClass null )

Constructs the view class instance based on the current configuration.

Parameters

string|null $viewClass optional null
Optional namespaced class name of the View class to instantiate.

Returns

Cake\View\View
\Cake\View\View

Throws

Cake\View\Exception\MissingViewException
If view class was not found.

setsource public

set( string|array $name , string|array|null|boolean $value null )

Saves a variable or an associative array of variables for use inside a template.

Parameters

string|array $name
A string or an array of data.
string|array|null|boolean $value optional null
Value in case $name is a string (which then works as the key). Unused if $name is an associative array, otherwise serves as the values to $name's keys.

Returns

mixed
$this

viewBuildersource public

viewBuilder( )

Get the view builder being used.

Returns

Cake\View\ViewBuilder
\Cake\View\ViewBuilder

viewOptionssource public

viewOptions( string|array|null $options null , boolean $merge true )

Get/Set valid view options in the object's _validViewOptions property. The property is created as an empty array if it is not set. If called without any parameters it will return the current list of valid view options. See createView().

Parameters

string|array|null $options optional null
string or array of string to be appended to _validViewOptions.
boolean $merge optional true
Whether to merge with or override existing valid View options. Defaults to true.

Returns

array
The updated view options as an array.

Properties summary

$_viewBuildersource

protected Cake\View\ViewBuilder

The view builder instance being used.

$viewClasssource

public string

The name of default View class.

Deprecated

3.1.0 Use $this->viewBuilder()->className() instead.
null

$viewVarssource

public array

Variables for the view

[]

© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/3.1/class-Cake.View.ViewVarsTrait.html