On this page
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.
Property Summary
-
$_viewBuilder protected
Cake\View\ViewBuilder|nullThe view builder instance being used.
Method Summary
createView() public
Constructs the view class instance based on the current configuration.
set() public
Saves a variable or an associative array of variables for use inside a template.
viewBuilder() public
Get the view builder being used.
Method Detail
createView() public
createView(string|null $viewClass = null): Cake\View\View
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\ViewThrows
Cake\View\Exception\MissingViewExceptionIf view class was not found.
set() public
set(array|string $name, mixed $value = null): $this
Saves a variable or an associative array of variables for use inside a template.
Parameters
array|string$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
$thisviewBuilder() public
viewBuilder(): Cake\View\ViewBuilder
Get the view builder being used.
Returns
Cake\View\ViewBuilderProperty Detail
$_viewBuilder protected
The view builder instance being used.
Type
Cake\View\ViewBuilder|null© 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/4.4/trait-Cake.View.ViewVarsTrait.html