Trait CellTrait
Provides cell() method for usage in Controller and View classes.
Property Summary
Method Summary
-
cell() protected
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
displayaction 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.
-
createCell() protected
Create and configure the cell instance.
Method Detail
cell() ¶ protected
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.
Parameters
-
string$cell You must indicate cell name, and optionally a cell action. e.g.:
TagCloud::smallListwill invokeView\Cell\TagCloudCell::smallList(),displayaction 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 toView\Cell\TagCloud::smallList(v1, v2)-
array<string, mixed>$options optional Options for Cell's constructor
Returns
Cake\View\CellThe cell instance
Throws
Cake\View\Exception\MissingCellExceptionIf Cell class was not found.
createCell() ¶ protected
createCell(class-string<Cake\View\Cell> $className, string $action, string|null $plugin, array<string, mixed> $options): Cake\View\Cell
Create and configure the cell instance.
Parameters
-
class-string<Cake\View\Cell>$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.
Returns
Cake\View\Cell