CellTrait
Provides cell() method for usage in Controller and View classes.
Table of Contents
Methods
- _createCell() : Cell
- Create and configure the cell instance.
- cell() : Cell
- Renders the given cell.
Methods
_createCell()
Create and configure the cell instance.
protected
_createCell(string $className, string $action, string|null $plugin, array<string, mixed> $options) : Cell
Parameters
- $className : string
-
The cell classname.
- $action : string
-
The action name.
- $plugin : string|null
-
The plugin name.
- $options : array<string, mixed>
-
The constructor options for the cell.
Return values
Cellcell()
Renders the given cell.
protected
cell(string $cell[, array<string|int, mixed> $data = [] ][, array<string, mixed> $options = [] ]) : 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.
Parameters
- $cell : string
-
You must indicate cell name, and optionally a cell action. e.g.:
TagCloud::smallList
will invokeView\Cell\TagCloudCell::smallList()
,display
action will be invoked by default when none is provided. - $data : array<string|int, mixed> = []
-
Additional arguments for cell method. e.g.:
cell('TagCloud::smallList', ['a1' => 'v1', 'a2' => 'v2'])
maps toView\Cell\TagCloud::smallList(v1, v2)
- $options : array<string, mixed> = []
-
Options for Cell's constructor
Tags
Return values
Cell —The cell instance