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 protectedCake\View\ViewBuilderThe view builder instance being used. 
- 
        $viewClass public deprecatedstringThe name of default View class. 
- 
        $viewVars publicarrayVariables for the view 
Method Summary
- 
          createView() publicConstructs the view class instance based on the current configuration. 
- 
          set() publicSaves a variable or an associative array of variables for use inside a template. 
- 
          viewBuilder() publicGet the view builder being used. 
- 
          viewOptions() publicGet/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(string|null $viewClass = null): Cake\View\ViewConstructs 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(string|array $name, mixed $value = null): $thisSaves 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
$thisviewBuilder() ¶ public
viewBuilder(): Cake\View\ViewBuilderGet the view builder being used.
Returns
Cake\View\ViewBuilderviewOptions() ¶ public
viewOptions(string|array|null $options = null, bool $merge = true): arrayGet/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
arrayThe updated view options as an array.
