A view class that is used for JSON responses.
It allows you to omit templates if you just need to emit JSON string as response.
In your controller, you could do the following:
$this->set(['posts' => $posts]); $this->viewBuilder()->setOption('serialize', true);
When the view is rendered, the $posts
view variable will be serialized into JSON.
You can also set multiple view variables for serialization. This will create a top level object containing all the named view variables:
$this->set(compact('posts', 'users', 'stuff')); $this->viewBuilder()->setOption('serialize', true);
The above would generate a JSON object that looks like:
{"posts": [...], "users": [...]}
You can also set 'serialize'
to a string or array to serialize only the specified view variables.
If you don't set the serialize
option, you will need a view template. You can use extended views to provide layout-like functionality.
You can also enable JSONP support by setting jsonp
option to true or a string to specify custom query string parameter name which will contain the callback function name.
string
'templates'
Constant for type used for App::path().
string
'plugin'
Constant for folder name containing files for overriding plugin templates.
string
'element'
Constant for view file type 'element'
string
'layout'
Constant for view file type 'layout'
string
'_match_all_'
The magic 'match-all' content type that views can use to behave as a fallback during content-type negotiation.
string
'template'
Constant for view file type 'template'.
Cake\View\ViewBlock
Cake\View\Helper\BreadcrumbsHelper
Cake\View\Helper\FlashHelper
Cake\View\Helper\FormHelper
Cake\View\Helper\HtmlHelper
Cake\View\Helper\NumberHelper
Cake\View\Helper\PaginatorHelper
Cake\View\Helper\TextHelper
Cake\View\Helper\TimeHelper
Cake\View\Helper\UrlHelper
array<string, mixed>
Runtime config
bool
Whether the config property has already been configured with defaults
string
The currently rendering view file. Used for resolving parent files.
string
Currently rendering an element. Used for finding parent fragments for elements.
array<string, mixed>
Default config options.
string
Default class name for new event objects.
Cake\Event\EventManagerInterface|null
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
string
File extension. Defaults to ".php".
Cake\View\HelperRegistry
Helpers collection
array<string>
The names of views and their parents used with View::extend();
array<string>
List of variables to collect from the associated controller.
array<string>
Holds an array of paths.
array<string[]>
Holds an array of plugin paths.
string
Response type.
array<string>
Content stack, used for nested templates that all use View::extend();
string
ViewBlock class.
bool
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 templates.
string
The Cache configuration View will use to store cached elements. Changing this will change the default configuration elements are stored under. You can also choose a cache config per element.
array
An array of names of built-in helpers to include.
string
The name of the layout file to render the template inside of. The name specified is the filename of the layout in templates/layout/
without the .php extension.
string
JSON layouts are located in the JSON subdirectory of Layouts/
string
Name of the controller that created the View if any.
string|null
The name of the plugin.
Cake\Http\ServerRequest
An instance of a \Cake\Http\ServerRequest object that contains information about the current request. This object contains all the information about a request and several methods for reading additional information about the request.
Cake\Http\Response
Reference to the Response object
string
JSON views are located in the 'json' subdirectory for controllers' views.
string
The name of the template file to render. The name specified is the filename in templates/<SubFolder>/
without the .php extension.
string
The name of the subfolder containing templates for this View.
string|null
The view theme to use.
array<string, mixed>
An array of variables
Constructor
Magic accessor for helpers.
Check that a view file path does not go outside of the defined template paths.
Deletes a single config key.
Reads a config key.
Writes a config key.
Create and configure the cell instance.
Returns data to be serialized.
Generate the cache configuration options for an element.
Sandbox method to evaluate a template / view script in.
Finds an element filename, returns false on failure.
Returns layout filename for this template as a string.
Find all sub templates path, based on $basePath If a prefix is defined in the current request, this method will prepend the prefixed template path to the $basePath, cascading up in case the prefix is nested. This is essentially used to find prefixed template paths for elements and layouts.
Returns filename of given action's template file as a string. CamelCased action names will be under_scored by default. This means that you can have LongActionNames that refer to long_action_names.php templates. You can change the inflection rule by overriding _inflectTemplateFileName.
Change the name of a view template file into underscored format.
Return all possible paths to find view files in order
Renders and returns output for given template filename with its array of data. Handles parent/extended templates.
Renders an element and fires the before and afterRender callbacks for it and writes to the cache if a cache is used
Serialize view vars.
Append to an existing or new block.
Set the content for a block. This will overwrite any existing content.
Get the names of all the existing blocks.
Create a cached block of view logic.
Renders the given cell.
Merge provided config with existing config. Unlike config()
which does a recursive merge for nested keys, this method does a simple merge.
Mime-type this view class renders as.
Turns off CakePHP's conventional mode of applying layout files. Layouts will not be automatically applied to rendered views.
Wrapper for creating and dispatching events.
Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string.
Checks if an element exists
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.
End a capturing block. The compliment to View::start()
Check if a block exists
Provides template or element extension/inheritance. Templates can extends a parent template and populate blocks in the parent template.
Fetch the content for a block. If a block is empty or undefined '' will be returned.
Returns the contents of the given View variable.
Get config value.
Returns the config for this specific key.
Retrieve the current template type
Get an iterator for element paths.
Returns the Cake\Event\EventManager manager instance for this object.
Get the name of the layout file to render the template inside of. The name specified is the filename of the layout in templates/layout/
without the .php extension.
Get path for layout files.
Get an iterator for layout paths.
Returns the View's controller name.
Returns the plugin name.
Gets the request instance.
Gets the response instance.
Get sub-directory for this template files.
Get the name of the template file to render. The name specified is the filename in templates/<SubFolder>/
without the .php extension.
Get path for templates files.
Get the current view theme.
Returns a list of variables available in the current View context
Get the helper registry in use by this View class.
Initialization hook method.
Returns if CakePHP's conventional mode of applying layout files is enabled. Disabled means that layouts will not be automatically applied to rendered views.
Loads a helper. Delegates to the HelperRegistry::load()
to load the helper
Load helpers only if serialization is disabled.
Convenience method to write a message to Log. See Log::write() for more information on writing to logs.
Splits a dot syntax plugin name into its plugin and filename. If $name does not have a dot, then index 0 will be null. It checks if the plugin is loaded, else filename will stay unchanged for filenames containing dot
Prepend to an existing or new block.
Render a JSON view.
Renders a layout. Returns output from _render().
Reset the content for a block. This will overwrite any existing content.
Saves a variable or an associative array of variables for use inside a template.
Sets the config.
Set the response content-type based on the view's contentType()
Set The cache configuration View will use to store cached elements
Returns the Cake\Event\EventManagerInterface instance for this object.
Set the name of the layout file to render the template inside of. The name specified is the filename of the layout in templates/layout/
without the .php extension.
Set path for layout files.
Sets the plugin name.
Sets the request objects and configures a number of controller properties based on the contents of the request. The properties that get set are:
Sets the response instance.
Set sub-directory for this template files.
Set the name of the template file to render. The name specified is the filename in templates/<SubFolder>/
without the .php extension.
Set path for templates files.
Set the view theme to use.
Start capturing output for a 'block'
__construct(Cake\Http\ServerRequest|null $request = null, Cake\Http\Response|null $response = null, Cake\Event\EventManager|null $eventManager = null, array<string, mixed> $viewOptions = [])
Constructor
Cake\Http\ServerRequest|null
$request optional Request instance.
Cake\Http\Response|null
$response optional Response instance.
Cake\Event\EventManager|null
$eventManager optional Event manager instance.
array<string, mixed>
$viewOptions optional View options. See {@link View::$_passedVars} for list of options which get set as class properties.
__get(string $name): Cake\View\Helper|null
Magic accessor for helpers.
string
$name Name of the attribute to get.
Cake\View\Helper|null
_checkFilePath(string $file, string $path): string
Check that a view file path does not go outside of the defined template paths.
Only paths that contain ..
will be checked, as they are the ones most likely to have the ability to resolve to files outside of the template paths.
string
$file The path to the template file.
string
$path Base path that $file should be inside of.
string
InvalidArgumentException
_configDelete(string $key): void
Deletes a single config key.
string
$key Key to delete.
void
Cake\Core\Exception\CakeException
_configRead(string|null $key): mixed
Reads a config key.
string|null
$key Key to read.
mixed
_configWrite(array<string, mixed>|string $key, mixed $value, string|bool $merge = false): void
Writes a config key.
array<string, mixed>|string
$key Key to write to.
mixed
$value Value to write.
string|bool
$merge optional True to merge recursively, 'shallow' for simple merge, false to overwrite, defaults to false.
void
Cake\Core\Exception\CakeException
_createCell(string $className, string $action, string|null $plugin, array<string, mixed> $options): Cake\View\Cell
Create and configure the cell instance.
string
$className The cell classname.
string
$action The action name.
string|null
$plugin The plugin name.
array<string, mixed>
$options The constructor options for the cell.
Cake\View\Cell
_dataToSerialize(array|string $serialize): mixed
Returns data to be serialized.
array|string
$serialize The name(s) of the view variable(s) that need(s) to be serialized.
mixed
_elementCache(string $name, array $data, array<string, mixed> $options): array
Generate the cache configuration options for an element.
string
$name Element name
array
$data Data
array<string, mixed>
$options Element options
array
_evaluate(string $templateFile, array $dataForView): string
Sandbox method to evaluate a template / view script in.
string
$templateFile Filename of the template.
array
$dataForView Data to include in rendered view.
string
_getElementFileName(string $name, bool $pluginCheck = true): string|false
Finds an element filename, returns false on failure.
string
$name The name of the element to find.
bool
$pluginCheck optional string|false
_getLayoutFileName(string|null $name = null): string
Returns layout filename for this template as a string.
string|null
$name optional The name of the layout to find.
string
Cake\View\Exception\MissingLayoutException
RuntimeException
_getSubPaths(string $basePath): array<string>
Find all sub templates path, based on $basePath If a prefix is defined in the current request, this method will prepend the prefixed template path to the $basePath, cascading up in case the prefix is nested. This is essentially used to find prefixed template paths for elements and layouts.
string
$basePath Base path on which to get the prefixed one.
array<string>
_getTemplateFileName(string|null $name = null): string
Returns filename of given action's template file as a string. CamelCased action names will be under_scored by default. This means that you can have LongActionNames that refer to long_action_names.php templates. You can change the inflection rule by overriding _inflectTemplateFileName.
string|null
$name optional Controller action to find template filename for
string
Cake\View\Exception\MissingTemplateException
RuntimeException
_inflectTemplateFileName(string $name): string
Change the name of a view template file into underscored format.
string
$name Name of file which should be inflected.
string
_paths(string|null $plugin = null, bool $cached = true): array<string>
Return all possible paths to find view files in order
string|null
$plugin optional Optional plugin name to scan for view files.
bool
$cached optional Set to false to force a refresh of view paths. Default true.
array<string>
_render(string $templateFile, array $data = []): string
Renders and returns output for given template filename with its array of data. Handles parent/extended templates.
string
$templateFile Filename of the template
array
$data optional Data to include in rendered view. If empty the current View::$viewVars will be used.
string
LogicException
_renderElement(string $file, array $data, array<string, mixed> $options): string
Renders an element and fires the before and afterRender callbacks for it and writes to the cache if a cache is used
string
$file Element file path
array
$data Data to render
array<string, mixed>
$options Element options
string
_serialize(array|string $serialize): string
Serialize view vars.
array|string
$serialize string
append(string $name, mixed $value = null): $this
Append to an existing or new block.
Appending to a new block will create the block.
string
$name Name of the block
mixed
$value optional The content for the block. Value will be type cast to string.
$this
assign(string $name, mixed $value): $this
Set the content for a block. This will overwrite any existing content.
string
$name Name of the block
mixed
$value The content for the block. Value will be type cast to string.
$this
blocks(): array<string>
Get the names of all the existing blocks.
array<string>
cache(callable $block, array<string, mixed> $options = []): string
Create a cached block of view logic.
This allows you to cache a block of view output into the cache defined in elementCache
.
This method will attempt to read the cache first. If the cache is empty, the $block will be run and the output stored.
callable
$block The block of code that you want to cache the output of.
array<string, mixed>
$options optional The options defining the cache key etc.
string
RuntimeException
cell(string $cell, array $data = [], array<string, mixed> $options = []): Cake\View\Cell
Renders the given cell.
Example:
// Taxonomy\View\Cell\TagCloudCell::smallList() $cell = $this->cell('Taxonomy.TagCloud::smallList', ['limit' => 10]); // App\View\Cell\TagCloudCell::smallList() $cell = $this->cell('TagCloud::smallList', ['limit' => 10]);
The display
action will be used by default when no action is provided:
// Taxonomy\View\Cell\TagCloudCell::display() $cell = $this->cell('Taxonomy.TagCloud');
Cells are not rendered until they are echoed.
string
$cell You must indicate cell name, and optionally a cell action. e.g.: TagCloud::smallList
will invoke View\Cell\TagCloudCell::smallList()
, display
action will be invoked by default when none is provided.
array
$data optional Additional arguments for cell method. e.g.: cell('TagCloud::smallList', ['a1' => 'v1', 'a2' => 'v2'])
maps to View\Cell\TagCloud::smallList(v1, v2)
array<string, mixed>
$options optional Options for Cell's constructor
Cake\View\Cell
Cake\View\Exception\MissingCellException
configShallow(array<string, mixed>|string $key, mixed|null $value = null): $this
Merge provided config with existing config. Unlike config()
which does a recursive merge for nested keys, this method does a simple merge.
Setting a specific value:
$this->configShallow('key', $value);
Setting a nested value:
$this->configShallow('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->configShallow(['one' => 'value', 'another' => 'value']);
array<string, mixed>|string
$key The key to set, or a complete array of configs.
mixed|null
$value optional The value to set.
$this
contentType(): string
Mime-type this view class renders as.
string
disableAutoLayout(): $this
Turns off CakePHP's conventional mode of applying layout files. Layouts will not be automatically applied to rendered views.
$this
dispatchEvent(string $name, array|null $data = null, object|null $subject = null): Cake\Event\EventInterface
Wrapper for creating and dispatching events.
Returns a dispatched event.
string
$name Name of the event.
array|null
$data optional Any value you wish to be transported with this event to it can be read by listeners.
object|null
$subject optional The object that this event applies to ($this by default).
Cake\Event\EventInterface
element(string $name, array $data = [], array<string, mixed> $options = []): string
Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string.
This realizes the concept of Elements, (or "partial layouts") and the $params array is used to send data to be used in the element. Elements can be cached improving performance by using the cache
option.
string
$name Name of template file in the templates/element/
folder, or MyPlugin.template
to use the template element from MyPlugin. If the element is not found in the plugin, the normal view path cascade will be searched.
array
$data optional Array of data to be made available to the rendered view (i.e. the Element)
array<string, mixed>
$options optional Array of options. Possible keys are:
string
Cake\View\Exception\MissingElementException
elementExists(string $name): bool
Checks if an element exists
string
$name Name of template file in the templates/element/
folder, or MyPlugin.template
to check the template element from MyPlugin. If the element is not found in the plugin, the normal view path cascade will be searched.
bool
enableAutoLayout(bool $enable = true): $this
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.
bool
$enable optional Boolean to turn on/off.
$this
end(): $this
End a capturing block. The compliment to View::start()
$this
exists(string $name): bool
Check if a block exists
string
$name Name of the block
bool
extend(string $name): $this
Provides template or element extension/inheritance. Templates can extends a parent template and populate blocks in the parent template.
string
$name The template or element to 'extend' the current one with.
$this
LogicException
LogicException
fetch(string $name, string $default = ''): string
Fetch the content for a block. If a block is empty or undefined '' will be returned.
string
$name Name of the block
string
$default optional Default text
string
get(string $var, mixed $default = null): mixed
Returns the contents of the given View variable.
string
$var The view var you want the contents of.
mixed
$default optional The default/fallback content of $var.
mixed
getConfig(string|null $key = null, mixed $default = null): mixed
Get config value.
Currently if config is not set it fallbacks to checking corresponding view var with underscore prefix. Using underscore prefixed special view vars is deprecated and this fallback will be removed in CakePHP 4.1.0.
string|null
$key optional The key to get or null for the whole config.
mixed
$default optional The return value when the key does not exist.
mixed
getConfigOrFail(string $key): mixed
Returns the config for this specific key.
The config value for this key must exist, it can never be null.
string
$key The key to get.
mixed
InvalidArgumentException
getCurrentType(): string
Retrieve the current template type
string
getElementPaths(string|null $plugin): Generator
Get an iterator for element paths.
string|null
$plugin The plugin to fetch paths for.
Generator
getEventManager(): Cake\Event\EventManagerInterface
Returns the Cake\Event\EventManager manager instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Cake\Event\EventManagerInterface
getLayout(): string
Get the name of the layout file to render the template inside of. The name specified is the filename of the layout in templates/layout/
without the .php extension.
string
getLayoutPath(): string
Get path for layout files.
string
getLayoutPaths(string|null $plugin): Generator
Get an iterator for layout paths.
string|null
$plugin The plugin to fetch paths for.
Generator
getName(): string
Returns the View's controller name.
string
getPlugin(): string|null
Returns the plugin name.
string|null
getRequest(): Cake\Http\ServerRequest
Gets the request instance.
Cake\Http\ServerRequest
getResponse(): Cake\Http\Response
Gets the response instance.
Cake\Http\Response
getSubDir(): string
Get sub-directory for this template files.
string
getTemplate(): string
Get the name of the template file to render. The name specified is the filename in templates/<SubFolder>/
without the .php extension.
string
getTemplatePath(): string
Get path for templates files.
string
getTheme(): string|null
Get the current view theme.
string|null
getVars(): array<string>
Returns a list of variables available in the current View context
array<string>
helpers(): Cake\View\HelperRegistry
Get the helper registry in use by this View class.
Cake\View\HelperRegistry
initialize(): void
Initialization hook method.
Properties like $helpers etc. cannot be initialized statically in your custom view class as they are overwritten by values from controller in constructor. So this method allows you to manipulate them as required after view instance is constructed.
void
isAutoLayoutEnabled(): bool
Returns if CakePHP's conventional mode of applying layout files is enabled. Disabled means that layouts will not be automatically applied to rendered views.
bool
loadHelper(string $name, array<string, mixed> $config = []): Cake\View\Helper
Loads a helper. Delegates to the HelperRegistry::load()
to load the helper
string
$name Name of the helper to load.
array<string, mixed>
$config optional Settings for the helper
Cake\View\Helper
loadHelpers(): $this
Load helpers only if serialization is disabled.
$this
log(string $message, string|int $level = LogLevel::ERROR, array|string $context = []): bool
Convenience method to write a message to Log. See Log::write() for more information on writing to logs.
string
$message Log message.
string|int
$level optional Error level.
array|string
$context optional Additional log data relevant to this message.
bool
pluginSplit(string $name, bool $fallback = true): array
Splits a dot syntax plugin name into its plugin and filename. If $name does not have a dot, then index 0 will be null. It checks if the plugin is loaded, else filename will stay unchanged for filenames containing dot
string
$name The name you want to plugin split.
bool
$fallback optional If true uses the plugin set in the current Request when parsed plugin is not loaded
array
prepend(string $name, mixed $value): $this
Prepend to an existing or new block.
Prepending to a new block will create the block.
string
$name Name of the block
mixed
$value The content for the block. Value will be type cast to string.
$this
render(string|null $template = null, string|false|null $layout = null): string
Render a JSON view.
Render triggers helper callbacks, which are fired before and after the template are rendered, as well as before and after the layout. The helper callbacks are called:
beforeRender
afterRender
beforeLayout
afterLayout
If View::$autoLayout is set to false
, the template will be returned bare.
Template and layout names can point to plugin templates or layouts. Using the Plugin.template
syntax a plugin template/layout/ can be used instead of the app ones. If the chosen plugin is not found the template will be located along the regular view path cascade.
string|null
$template optional The template being rendered.
string|false|null
$layout optional The layout being rendered.
string
renderLayout(string $content, string|null $layout = null): string
Renders a layout. Returns output from _render().
Several variables are created for use in layout.
string
$content Content to render in a template, wrapped by the surrounding layout.
string|null
$layout optional Layout name
string
Cake\Core\Exception\CakeException
reset(string $name): $this
Reset the content for a block. This will overwrite any existing content.
string
$name Name of the block
$this
set(array|string $name, mixed $value = null): $this
Saves a variable or an associative array of variables for use inside a template.
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.
$this
RuntimeException
setConfig(array<string, mixed>|string $key, mixed|null $value = null, bool $merge = true): $this
Sets the config.
Setting a specific value:
$this->setConfig('key', $value);
Setting a nested value:
$this->setConfig('some.nested.key', $value);
Updating multiple config settings at the same time:
$this->setConfig(['one' => 'value', 'another' => 'value']);
array<string, mixed>|string
$key The key to set, or a complete array of configs.
mixed|null
$value optional The value to set.
bool
$merge optional Whether to recursively merge or overwrite existing config, defaults to true.
$this
Cake\Core\Exception\CakeException
setContentType(): void
Set the response content-type based on the view's contentType()
void
setElementCache(string $elementCache): $this
Set The cache configuration View will use to store cached elements
string
$elementCache Cache config name.
$this
setEventManager(Cake\Event\EventManagerInterface $eventManager): $this
Returns the Cake\Event\EventManagerInterface instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Cake\Event\EventManagerInterface
$eventManager the eventManager to set
$this
setLayout(string $name): $this
Set the name of the layout file to render the template inside of. The name specified is the filename of the layout in templates/layout/
without the .php extension.
string
$name Layout file name to set.
$this
setLayoutPath(string $path): $this
Set path for layout files.
string
$path Path for layout files.
$this
setPlugin(string|null $name): $this
Sets the plugin name.
string|null
$name Plugin name.
$this
setRequest(Cake\Http\ServerRequest $request): $this
Sets the request objects and configures a number of controller properties based on the contents of the request. The properties that get set are:
Cake\Http\ServerRequest
$request Request instance.
$this
setResponse(Cake\Http\Response $response): $this
Sets the response instance.
Cake\Http\Response
$response Response instance.
$this
setSubDir(string $subDir): $this
Set sub-directory for this template files.
string
$subDir Sub-directory name.
$this
setTemplate(string $name): $this
Set the name of the template file to render. The name specified is the filename in templates/<SubFolder>/
without the .php extension.
string
$name Template file name to set.
$this
setTemplatePath(string $path): $this
Set path for templates files.
string
$path Path for template files.
$this
setTheme(string|null $theme): $this
Set the view theme to use.
string|null
$theme Theme name.
$this
start(string $name): $this
Start capturing output for a 'block'
You can use start on a block multiple times to append or prepend content in a capture mode.
// Append content to an existing block. $this->start('content'); echo $this->fetch('content'); echo 'Some new content'; $this->end(); // Prepend content to an existing block $this->start('content'); echo 'Some new content'; echo $this->fetch('content'); $this->end();
string
$name The name of the block to capture for.
$this
Cake\View\ViewBlock
Cake\View\Helper\BreadcrumbsHelper
Cake\View\Helper\FlashHelper
Cake\View\Helper\FormHelper
Cake\View\Helper\HtmlHelper
Cake\View\Helper\NumberHelper
Cake\View\Helper\PaginatorHelper
Cake\View\Helper\TextHelper
Cake\View\Helper\TimeHelper
Cake\View\Helper\UrlHelper
Runtime config
array<string, mixed>
Whether the config property has already been configured with defaults
bool
The currently rendering view file. Used for resolving parent files.
string
Currently rendering an element. Used for finding parent fragments for elements.
string
Default config options.
Use ViewBuilder::setOption()/setOptions() in your controller to set these options.
serialize
: Option to convert a set of view variables into a serialized response. Its value can be a string for single variable name or array for multiple names. If true all view variables will be serialized. If null or false normal view template will be rendered.jsonOptions
: Options for json_encode(). For e.g. JSON_HEX_TAG | JSON_HEX_APOS
.jsonp
: Enables JSONP support and wraps response in callback function provided in query string. array<string, mixed>
Default class name for new event objects.
string
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
Cake\Event\EventManagerInterface|null
File extension. Defaults to ".php".
string
Helpers collection
Cake\View\HelperRegistry
The names of views and their parents used with View::extend();
array<string>
List of variables to collect from the associated controller.
array<string>
Holds an array of paths.
array<string>
Holds an array of plugin paths.
array<string[]>
Response type.
string
Content stack, used for nested templates that all use View::extend();
array<string>
ViewBlock class.
string
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 templates.
bool
The Cache configuration View will use to store cached elements. Changing this will change the default configuration elements are stored under. You can also choose a cache config per element.
string
An array of names of built-in helpers to include.
array
The name of the layout file to render the template inside of. The name specified is the filename of the layout in templates/layout/
without the .php extension.
string
JSON layouts are located in the JSON subdirectory of Layouts/
string
Name of the controller that created the View if any.
string
The name of the plugin.
string|null
An instance of a \Cake\Http\ServerRequest object that contains information about the current request. This object contains all the information about a request and several methods for reading additional information about the request.
Cake\Http\ServerRequest
Reference to the Response object
Cake\Http\Response
JSON views are located in the 'json' subdirectory for controllers' views.
string
The name of the template file to render. The name specified is the filename in templates/<SubFolder>/
without the .php extension.
string
The name of the subfolder containing templates for this View.
string
The view theme to use.
string|null
An array of variables
array<string, mixed>
© 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/class-Cake.View.JsonView.html