Class Cell
Cell base.
Properties summary
- $View protected
\Cake\View\ViewInstance of the View created during rendering. Won't be set until after Cell::__toString()/render() is called.
- $_cache protected
array|boolCaching setup.
- $_eventClass protected
stringDefault class name for new event objects.
- $_eventManager protected
\Cake\Event\EventManagerInterface|\Cake\Event\EventManagerInstance of the Cake\Event\EventManager this object is using to dispatch inner events.
- $_modelFactories protected
arrayA list of overridden model factory functions.
- $_modelType protected
stringThe model type to use.
- $_tableLocator protected
\Cake\ORM\Locator\LocatorInterfaceTable locator instance
- $_validCellOptions protected
arrayList of valid options (constructor's fourth arguments) Override this property in subclasses to whitelist which options you want set as properties in your Cell.
- $_validViewOptions protected
arrayThese properties can be set directly on Cell and passed to the View as options.
- $_viewBuilder protected
\Cake\View\ViewBuilderThe view builder instance being used.
- $action protected
stringThe cell's action to invoke.
- $args protected
arrayArguments to pass to cell's action.
- $modelClass public
string|false|nullThis object's primary model class name. Should be a plural form.
- $request protected
\Cake\Http\ServerRequestAn instance of a Cake\Http\ServerRequest object that contains information about the current request.
- $response protected
\Cake\Http\ResponseAn instance of a Response object that contains information about the impending response
- $viewClass public
string|nullThe name of default View class.
- $viewVars public
arrayVariables 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
__construct() public
__construct(\Cake\Http\ServerRequest $request, \Cake\Http\Response $response, \Cake\Event\EventManager $eventManager, array $cellOptions)
Constructor.
Parameters
-
\Cake\Http\ServerRequest|null$request optional The request to use in the cell.
-
\Cake\Http\Response|null$response optional The response to use in the cell.
-
\Cake\Event\EventManager|null$eventManager optional The eventManager to bind events to.
-
array$cellOptions optional Cell options to apply.
__debugInfo() public
__debugInfo()
Debug info.
Returns
array__get() public
__get(mixed $name)
Magic accessor for removed properties.
Parameters
-
string$name Property name
Returns
mixed__set() public
__set(mixed $name, mixed $value)
Magic setter for removed properties.
Parameters
-
string$name Property name.
-
mixed$value Value to set.
__toString() public
__toString()
Magic method.
Starts the rendering process when Cell is echoed.
Note This method will trigger an error when view rendering has a problem. This is because PHP will not allow a __toString() method to throw an exception.
Returns
stringRendered cell
Throws
ErrorInclude error details for PHP 7 fatal errors.
_cacheConfig() protected
_cacheConfig(mixed $action, mixed $template)
Generate the cache key to use for this cell.
If the key is undefined, the cell class and action name will be used.
Parameters
-
string$action The action invoked.
-
string|null$template optional The name of the template to be rendered.
Returns
arrayThe cache configuration.
_setModelClass() protected
_setModelClass(mixed $name)
Set the modelClass and modelKey properties based on conventions.
If the properties are already set they will not be overwritten
Parameters
-
string$name Class name.
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\ViewThrows
Cake\View\Exception\MissingViewExceptionIf view class was not found.
dispatchEvent() public
dispatchEvent(mixed $name, mixed $data, mixed $subject)
Wrapper for creating and dispatching events.
Returns a dispatched event.
Parameters
-
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).
Returns
\Cake\Event\EventeventManager() public
eventManager(\Cake\Event\EventManager $eventManager)
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.
Parameters
-
\Cake\Event\EventManager|null$eventManager optional the eventManager to set
Returns
\Cake\Event\EventManagergetEventManager() public
getEventManager()
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.
Returns
\Cake\Event\EventManagergetModelType() public
getModelType()
Get the model type to be used by this class
Returns
stringgetTableLocator() public
getTableLocator()
Gets the table locator.
Returns
\Cake\ORM\Locator\LocatorInterfaceinitialize() public
initialize()
Initialization hook method.
Implement this method to avoid having to overwrite the constructor and calling parent::__construct().
loadModel() public
loadModel(mixed $modelClass, mixed $modelType)
Loads and constructs repository objects required by this object
Typically used to load ORM Table objects as required. Can also be used to load other types of repository objects your application uses.
If a repository provider does not return an object a MissingModelException will be thrown.
Parameters
-
string|null$modelClass optional Name of model class to load. Defaults to $this->modelClass. The name can be an alias like
'Post'or FQCN likeApp\Model\Table\PostsTable::class.-
string|null$modelType optional The type of repository to load. Defaults to the modelType() value.
Returns
\Cake\Datasource\RepositoryInterfaceThe model instance created.
Throws
Cake\Datasource\Exception\MissingModelExceptionIf the model class cannot be found.
InvalidArgumentExceptionWhen using a type that has not been registered.
UnexpectedValueExceptionIf no model type has been defined
modelFactory() public
modelFactory(mixed $type, callable $factory)
Override a existing callable to generate repositories of a given type.
Parameters
-
string$type The name of the repository type the factory function is for.
-
callable$factory The factory function used to create instances.
modelType() public
modelType(mixed $modelType)
Set or get the model type to be used by this class
Parameters
-
string|null$modelType optional The model type or null to retrieve the current
Returns
string|$thisrender() public
render(mixed $template)
Render the cell.
Parameters
-
string|null$template optional Custom template name to render. If not provided (null), the last value will be used. This value is automatically set by
CellTrait::cell().
Returns
stringThe rendered cell.
Throws
Cake\View\Exception\MissingCellViewExceptionWhen a MissingTemplateException is raised during rendering.
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
$thissetEventManager() public
setEventManager(\Cake\Event\EventManager $eventManager)
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.
Parameters
-
\Cake\Event\EventManager$eventManager the eventManager to set
Returns
$thissetModelType() public
setModelType(mixed $modelType)
Set the model type to be used by this class
Parameters
-
string$modelType The model type
Returns
$thissetTableLocator() public
setTableLocator(\Cake\ORM\Locator\LocatorInterface $tableLocator)
Sets the table locator.
Parameters
-
\Cake\ORM\Locator\LocatorInterface$tableLocator LocatorInterface instance.
Returns
$thistableLocator() public
tableLocator(\Cake\ORM\Locator\LocatorInterface $tableLocator)
Sets the table locator.
If no parameters are passed, it will return the currently used locator.
Parameters
-
\Cake\ORM\Locator\LocatorInterface|null$tableLocator optional LocatorInterface instance.
Returns
\Cake\ORM\Locator\LocatorInterfaceviewBuilder() public
viewBuilder()
Get the view builder being used.
Returns
\Cake\View\ViewBuilderviewOptions() 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
arrayThe updated view options as an array.
Property Detail
$View protected
Instance of the View created during rendering. Won't be set until after Cell::__toString()/render() is called.
Type
\Cake\View\View$_cache protected
Caching setup.
Type
array|bool$_eventClass protected
Default class name for new event objects.
Type
string$_eventManager protected
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
Type
\Cake\Event\EventManagerInterface|\Cake\Event\EventManager$_modelFactories protected
A list of overridden model factory functions.
Type
array$_modelType protected
The model type to use.
Type
string$_tableLocator protected
Table locator instance
Type
\Cake\ORM\Locator\LocatorInterface$_validCellOptions protected
List of valid options (constructor's fourth arguments) Override this property in subclasses to whitelist which options you want set as properties in your Cell.
Type
array$_validViewOptions protected
These properties can be set directly on Cell and passed to the View as options.
Type
array$_viewBuilder protected
The view builder instance being used.
Type
\Cake\View\ViewBuilder$action protected
The cell's action to invoke.
Type
string$args protected
Arguments to pass to cell's action.
Type
array$modelClass public
This object's primary model class name. Should be a plural form.
CakePHP will not inflect the name.
Example: For an object named 'Comments', the modelClass would be 'Comments'. Plugin classes should use Plugin.Comments style names to correctly load models from the correct plugin.
Use false to not use auto-loading on this object. Null auto-detects based on controller name.
Type
string|false|null$request protected
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.
Type
\Cake\Http\ServerRequest$response protected
An instance of a Response object that contains information about the impending response
Type
\Cake\Http\Response$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/class-Cake.View.Cell.html