Provides an API for iteratively building a view up.
Once you have configured the view and established all the context you can create a view instance with build().
$_autoLayout protected boolean|null$_className protected string|nullThe view class name to use. Can either use plugin notation, a short name or a fully namespaced classname.
$_helpers protected array$_layout protected string|null|false$_layoutPath protected string|null$_name protected string|null$_options protected array$_plugin protected string|null|false$_template protected string|null$_templatePath protected string|null$_theme protected string|null|false$_vars protected arrayTurns 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.
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.
Gets the name of the view file to render. The name specified is the filename in /src/Template/
Returns if CakePHP's conventional mode of applying layout files is enabled. Disabled means that layouts will not be automatically applied to rendered views.
Serializes the view builder object to a value that can be natively serialized and re-used to clone this builder instance.
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.
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.
Sets the name of the view file to render. The name specified is the filename in /src/Template/
Get/set the name of the view file to render. The name specified is the filename in /src/Template/
autoLayout( boolean|null $enable = null )
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.
$enable optional null Cake\View\ViewBuilderbuild( array $vars = [] , Cake\Http\ServerRequest $request = null , Cake\Http\Response $response = null , Cake\Event\EventManager $events = null )
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.
$vars optional [] Cake\Http\ServerRequest $request optional null Cake\Http\Response $response optional null Cake\Event\EventManager $events optional null Cake\View\ViewCake\View\Exception\MissingViewExceptionclassName( string|null $name = null )
Get/set the view classname.
Accepts either a short name (Ajax) a plugin name (MyPlugin.Ajax) or a fully namespaced name (App\View\AppView).
$name optional null The class name for the view. Can be a plugin.class name reference, a short alias, or a fully namespaced name.
Cake\View\ViewBuildercreateFromArray( array $config )
Configures a view builder instance from serialized config.
$config disableAutoLayout( )
Turns off CakePHP's conventional mode of applying layout files.
Setting to off means that layouts will not be automatically applied to rendered views.
enableAutoLayout( boolean $enable = true )
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.
$enable optional true getLayout( )
Gets the name of the layout file to render the view inside of.
getTemplate( )
Gets the name of the view file to render. The name specified is the filename in /src/Template/
getVar( string $name )
Get view var
$name hasVar( string $name )
Check if view var is set.
$name helpers( array $helpers = null , boolean $merge = true )
The helpers to use
$helpers optional null $merge optional true Cake\View\ViewBuilderisAutoLayoutEnabled( )
Returns if CakePHP's conventional mode of applying layout files is enabled. Disabled means that layouts will not be automatically applied to rendered views.
jsonSerialize( )
Serializes the view builder object to a value that can be natively serialized and re-used to clone this builder instance.
JsonSerializable::jsonSerialize() layout( string|null $name = null )
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.
$name optional null Cake\View\ViewBuilderlayoutPath( string|null $path = null )
Get/set path for layout files.
$path optional null Cake\View\ViewBuildername( string|null $name = null )
Get/set the view name
$name optional null Cake\View\ViewBuilderoptions( array $options = null , boolean $merge = true )
Set additional options for the view.
This lets you provide custom constructor arguments to application/plugin view classes.
$options optional null $merge optional true Cake\View\ViewBuilderplugin( string|null|false $name = null )
The plugin name to use
$name optional null Plugin name. If null returns current plugin. Use false to remove the current plugin name.
Cake\View\ViewBuilderserialize( )
Serializes the view builder object.
Serializable::serialize() setClassName( string|null $name )
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.
$name setHelpers( array $helpers , boolean $merge = true )
Sets the helpers to use.
$helpers $merge optional true setLayout( string|null|false $name )
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.
$name setLayoutPath( string|null $path )
Sets path for layout files.
$path setName( string|null $name )
Sets the view name.
$name setOptions( array $options , boolean $merge = true )
Sets additional options for the view.
This lets you provide custom constructor arguments to application/plugin view classes.
$options $merge optional true setPlugin( string|null|false $name )
Sets the plugin name to use.
False to remove current plugin name is deprecated as of 3.4.0. Use directly null instead.
$name Plugin name. Use null or false to remove the current plugin name.
setTemplate( string|null $name )
Sets the name of the view file to render. The name specified is the filename in /src/Template/
$name setTemplatePath( string|null $path )
Sets path for template files.
$path setTheme( string|null|false $theme )
Sets the view theme to use.
False to remove current theme is deprecated as of 3.4.0. Use directly null instead.
$theme Theme name. Use null or false to remove the current theme.
setVar( string $name , mixed $value = null )
Saves a variable for use inside a template.
$name $value optional null setVars( array $data , boolean $merge = true )
Saves view vars for use inside templates.
$data $merge optional true template( string|null $name = null )
Get/set the name of the view file to render. The name specified is the filename in /src/Template/
$name optional null Cake\View\ViewBuildertemplatePath( string|null $path = null )
Get/set path for template files.
$path optional null Cake\View\ViewBuildertheme( string|null|false $theme = null )
The view theme to use.
$theme optional null Theme name. If null returns current theme. Use false to remove the current theme.
Cake\View\ViewBuilderunserialize( string $data )
Unserializes the view builder object.
$data Serializable::unserialize() protected string|null
The view class name to use. Can either use plugin notation, a short name or a fully namespaced classname.
protected array
Additional options used when constructing the view.
This options array lets you provide custom constructor arguments to application/plugin view classes.
[]
© 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.8/class-Cake.View.ViewBuilder.html