Skip to content

Commit f5ade58

Browse files
committed
Update cell documentation
1 parent 82f33d4 commit f5ade58

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

user_guide_src/source/changelogs/v4.3.5.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@ Message Changes
1818
Changes
1919
*******
2020

21+
- **make:cell** When creating a new cell, the controller would always have the ``Cell`` suffixed to the class name.
22+
For the view file, the final ``_cell`` is always removed.
23+
- **Cells** For compatibility with previous versions, view filenames ending with ``_cell`` can still be
24+
located by the ``Cell`` as long as auto-detection of view file is enabled (via setting the ``$view`` property
25+
to an empty string).
26+
2127
Deprecations
2228
************
2329

2430
Bugs Fixed
2531
**********
2632

33+
- **make:cell** Fixed generating view files as classes.
34+
- **make:cell** Fixed treatment of single word class input for case-insensitive OS.
35+
2736
See the repo's
2837
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
2938
for a complete list of bugs fixed.

user_guide_src/source/cli/cli_generators.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ Usage:
5959

6060
Argument:
6161
=========
62-
* ``name``: The name of the cell class. It should be in PascalCase.
62+
* ``name``: The name of the cell class. It should be in PascalCase. **[REQUIRED]**
6363

6464
Options:
6565
========
6666
* ``--namespace``: Set the root namespace. Defaults to value of ``APP_NAMESPACE``.
67-
* ``--suffix``: Append the component suffix to the generated class name.
6867
* ``--force``: Set this flag to overwrite existing files on destination.
6968

7069
make:command

user_guide_src/source/outgoing/view_cells.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,15 @@ Controlled Cells
8080

8181
.. versionadded:: 4.3.0
8282

83-
Controlled Cells have two primary goals: to make it as fast as possible to build the cell, and provide additional logic and flexibility to your views, if they need it. The class must extend ``CodeIgniter\View\Cells\Cell``. They should have a view file in the same folder. By convention the class name should be PascalCase and the view should be the snake_cased version of the class name. So, for example, if you have a ``MyCell`` class, the view file should be ``my_cell.php``.
83+
Controlled cells have two primary goals: to make it as fast as possible to build the cell, and provide additional logic and
84+
flexibility to your views, if they need it. The class must extend ``CodeIgniter\View\Cells\Cell``. They should have a view file
85+
in the same folder. By convention, the class name should be in PascalCase suffixed with ``Cell`` and the view should be
86+
the snake_cased version of the class name, without the suffix. For example, if you have a ``MyCell`` class, the view file
87+
should be ``my.php``.
88+
89+
.. note:: Prior to v4.3.5, the generated view file ends with ``_cell.php``. This was deemed incorrect and corrected accordingly.
90+
For backward compatibility, existing view files ending with ``_cell.php`` will still be located and loaded. However, it is
91+
recommended to update the filenames to remove the trailing ``_cell``.
8492

8593
Creating a Controlled Cell
8694
==========================
@@ -99,7 +107,7 @@ At the most basic level, all you need to implement within the class are public p
99107
public $message;
100108
}
101109

102-
// app/Cells/alert_message_cell.php
110+
// app/Cells/alert_message.php
103111
<div class="alert alert-<?= esc($type, 'attr') ?>">
104112
<?= esc($message) ?>
105113
</div>
@@ -199,7 +207,7 @@ If you need to perform additional logic for one or more properties you can use c
199207
}
200208
}
201209

202-
// app/Cells/alert_message_cell.php
210+
// app/Cells/alert_message.php
203211
<div>
204212
<p>type - <?= esc($type) ?></p>
205213
<p>message - <?= esc($message) ?></p>
@@ -230,7 +238,7 @@ Sometimes you need to perform additional logic for the view, but you don't want
230238
}
231239
}
232240

233-
// app/Cells/recent_posts_cell.php
241+
// app/Cells/recent_posts.php
234242
<ul>
235243
<?php foreach ($posts as $post): ?>
236244
<li><?= $this->linkPost($post) ?></li>

0 commit comments

Comments
 (0)