Class Cell
Cell base.
Constants
-
stringTEMPLATE_FOLDER ¶'cell'Constant for folder name containing cell templates.
Property Summary
-
$View protected
Cake\View\ViewInstance of the View created during rendering. Won't be set until after Cell::__toString()/render() is called.
-
$action protected
stringThe cell's action to invoke.
-
$args protected
arrayArguments to pass to cell's action.
-
$cache protected
array|boolCaching setup.
-
$defaultTable protected
string|nullThis object's default table alias.
-
$eventClass protected
stringDefault class name for new event objects.
-
$eventManager protected
Cake\Event\EventManagerInterfaceInstance of the Cake\Event\EventManager this object is using to dispatch inner events.
-
$name public @property
string|nullThe controller or cell name.
-
$plugin protected
string|nullThe plugin name this cell belongs to.
-
$request public @property
Cake\Http\ServerRequest|nullThe request being handled.
-
$response public @property
Cake\Http\Response|nullThe response being built.
-
$tableLocator protected
Cake\ORM\Locator\LocatorInterface|nullTable locator instance
-
$validCellOptions protected
array<string>List of valid options (constructor's fourth arguments) Override this property in subclasses to allow which options you want set as properties in your Cell.
-
$viewBuilder protected
Cake\View\ViewBuilder|nullThe view builder instance being used.
Method Summary
-
__construct() public
Constructor.
-
__debugInfo() public
Debug info.
-
__toString() public
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.
-
cacheConfig() protected
Generate the cache key to use for this cell.
If the key is undefined, the cell class and action name will be used.
-
createView() public
Constructs the view class instance based on the current configuration.
-
dispatchEvent() public
Wrapper for creating and dispatching events.
Returns a dispatched event.
-
fetchTable() public
Convenience method to get a table instance.
-
getEventManager() public
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.
-
getTableLocator() public
Gets the table locator.
-
initialize() public
Initialization hook method.
Implement this method to avoid having to overwrite the constructor and calling parent::__construct().
-
render() public
Render the cell.
-
set() public
Saves a variable or an associative array of variables for use inside a template.
-
setEventManager() public
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.
-
setTableLocator() public
Sets the table locator.
-
viewBuilder() public
Get the view builder being used.
Method Detail
__construct() ¶ public
__construct(Cake\Http\ServerRequest $request, Cake\Http\Response $response, Cake\Event\EventManagerInterface|null $eventManager = null, array<string, mixed> $cellOptions = [])
Constructor.
Parameters
-
Cake\Http\ServerRequest$request The request to use in the cell.
-
Cake\Http\Response$response The response to use in the cell.
-
Cake\Event\EventManagerInterface|null$eventManager optional The eventManager to bind events to.
-
array<string, mixed>$cellOptions optional Cell options to apply.
__toString() ¶ public
__toString(): string
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(string $action, string|null $template = null): array
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.
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.
dispatchEvent() ¶ public
dispatchEvent(string $name, array $data = [], TSubject|null $subject = null): Cake\Event\EventInterface<TSubject>
Wrapper for creating and dispatching events.
Returns a dispatched event.
Templates
TSubject
of object = $this Parameters
-
string$name Name of the event.
-
array$data optional Any value you wish to be transported with this event to it can be read by listeners.
-
TSubject|null$subject optional The object that this event applies to ($this by default).
Returns
Cake\Event\EventInterface<TSubject>fetchTable() ¶ public
fetchTable(class-string<T>|string|null $alias = null, array<string, mixed> $options = []): $alias is class-string<T> ? T : \Cake\ORM\Table
Convenience method to get a table instance.
Templates
T
of \Cake\ORM\Table Parameters
-
class-string<T>|string|null$alias optional The alias name you want to get. Should be in CamelCase format. If
nullthen the value of $defaultTable property is used.-
array<string, mixed>$options optional The options you want to build the table with. If a table has already been loaded the registry options will be ignored.
Returns
$alias is class-string<T> ? T : \Cake\ORM\TableThrows
Cake\Core\Exception\CakeExceptionIf `$alias` argument and `$defaultTable` property both are `null`.
See Also
getEventManager() ¶ public
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.
Returns
Cake\Event\EventManagerInterfacegetTableLocator() ¶ public
getTableLocator(): Cake\ORM\Locator\LocatorInterface
Gets the table locator.
Returns
Cake\ORM\Locator\LocatorInterfaceinitialize() ¶ public
initialize(): void
Initialization hook method.
Implement this method to avoid having to overwrite the constructor and calling parent::__construct().
Returns
voidrender() ¶ public
render(string|null $template = null): string
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\MissingCellTemplateException|BadMethodCallExceptionset() ¶ 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
$thissetEventManager() ¶ public
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.
Parameters
-
Cake\Event\EventManagerInterface$eventManager the eventManager to set
Returns
$thissetTableLocator() ¶ public
setTableLocator(Cake\ORM\Locator\LocatorInterface $tableLocator): $this
Sets the table locator.
Parameters
-
Cake\ORM\Locator\LocatorInterface$tableLocator LocatorInterface instance.
Returns
$thisviewBuilder() ¶ public
viewBuilder(): Cake\View\ViewBuilder
Get the view builder being used.
Returns
Cake\View\ViewBuilderProperty 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$eventManager ¶ protected
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
Type
Cake\Event\EventManagerInterface$validCellOptions ¶ protected
List of valid options (constructor's fourth arguments) Override this property in subclasses to allow which options you want set as properties in your Cell.
Type
array<string>