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.
Properties summary
- $_validViewOptions public
array
- $_viewBuilder protected
\Cake\View\ViewBuilder
The view builder instance being used.
- $viewClass public
string|null
The name of default View class.
- $viewVars public
array
Variables for the view.
Method Summary
- viewOptions() public
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()
.
Method Detail
createView() public
createView(mixed $viewClass)
Constructs the view class instance based on the current configuration.
Parameters
-
string|null
$viewClass optional Optional namespaced class name of the View class to instantiate.
Returns
\Cake\View\View
Throws
Cake\View\Exception\MissingViewException
If view class was not found.
set() public
set(mixed $name, mixed $value)
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.
-
mixed
$value optional 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
$this
viewBuilder() public
viewBuilder()
Get the view builder being used.
Returns
\Cake\View\ViewBuilder
viewOptions() public
viewOptions(mixed $options, mixed $merge)
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 string or array of string to be appended to _validViewOptions.
-
bool
$merge optional Whether to merge with or override existing valid View options. Defaults to
true
.
Returns
array
The updated view options as an array.
Property Detail
$_validViewOptions public
Type
array
$_viewBuilder protected
The view builder instance being used.
Type
\Cake\View\ViewBuilder
$viewClass public
The name of default View class.
Type
string|null
$viewVars public
Variables for the view.
Deprecated: This property will be removed in 4.x. Inside controller context use $this->set()
instead, also see $this->viewBuilder()->getVar()
. In view context it will be a protected property View::$viewVars
.
Type
array
© 2005–present 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.
https://api.cakephp.org/3.9/trait-Cake.View.ViewVarsTrait.html