Skip to content

Commit bfa6137

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.5
2 parents 3da89ac + 2df4a3f commit bfa6137

File tree

12 files changed

+53
-21
lines changed

12 files changed

+53
-21
lines changed

system/Commands/Generators/CellGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class CellGenerator extends BaseCommand
4040
*
4141
* @var string
4242
*/
43-
protected $description = 'Generates a new Cell file and its view.';
43+
protected $description = 'Generates a new Controlled Cell file and its view.';
4444

4545
/**
4646
* The Command's Usage
@@ -55,7 +55,7 @@ class CellGenerator extends BaseCommand
5555
* @var array<string, string>
5656
*/
5757
protected $arguments = [
58-
'name' => 'The cell class name.',
58+
'name' => 'The Controlled Cell class name.',
5959
];
6060

6161
/**

system/Debug/Toolbar/Views/toolbar.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</style>
2424

2525
<script id="toolbar_js">
26-
var ciSiteURL = "<?= site_url() ?>"
26+
var ciSiteURL = "<?= rtrim(site_url(), '/') ?>"
2727
<?= file_get_contents(__DIR__ . '/toolbar.js') ?>
2828
</script>
2929
<div id="debug-icon" class="debug-bar-ndisplay">

system/HotReloader/HotReloader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ final class HotReloader
1818
{
1919
public function run(): void
2020
{
21+
if (session_status() === PHP_SESSION_ACTIVE) {
22+
session_write_close();
23+
}
24+
2125
ini_set('zlib.output_compression', 'Off');
2226

2327
header('Cache-Control: no-store');

user_guide_src/source/incoming/filters.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,12 @@ You should define as many aliases as you need.
119119
$globals
120120
--------
121121

122-
The second section allows you to define any filters that should be applied to every request made by the framework.
122+
The second section allows you to define any filters that should be applied to every valid request made by the framework.
123+
123124
You should take care with how many you use here, since it could have performance implications to have too many
124-
run on every request. Filters can be specified by adding their alias to either the before or after array:
125+
run on every request.
126+
127+
Filters can be specified by adding their alias to either the ``before`` or ``after`` array:
125128

126129
.. literalinclude:: filters/005.php
127130

@@ -130,14 +133,18 @@ Except for a Few URIs
130133

131134
There are times where you want to apply a filter to almost every request, but have a few that should be left alone.
132135
One common example is if you need to exclude a few URI's from the CSRF protection filter to allow requests from
133-
third-party websites to hit one or two specific URI's, while keeping the rest of them protected. To do this, add
136+
third-party websites to hit one or two specific URI's, while keeping the rest of them protected.
137+
138+
To do this, add
134139
an array with the ``except`` key and a URI path (relative to BaseURL) to match as the value alongside the alias:
135140

136141
.. literalinclude:: filters/006.php
137142

138143
Any place you can use a URI path (relative to BaseURL) in the filter settings, you can use a regular expression or, like in this example, use
139144
an asterisk (``*``) for a wildcard that will match all characters after that. In this example, any URI path starting with ``api/``
140-
would be exempted from CSRF protection, but the site's forms would all be protected. If you need to specify multiple
145+
would be exempted from CSRF protection, but the site's forms would all be protected.
146+
147+
If you need to specify multiple
141148
URI paths, you can use an array of URI path patterns:
142149

143150
.. literalinclude:: filters/007.php

user_guide_src/source/incoming/filters/004.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class Filters extends BaseConfig
88
{
99
public array $aliases = [
10-
'apiPrep' => [
10+
'api-prep' => [
1111
\App\Filters\Negotiate::class,
1212
\App\Filters\ApiAuth::class,
1313
],

user_guide_src/source/incoming/filters/008.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Filters extends BaseConfig
99
// ...
1010

1111
public array $methods = [
12-
'post' => ['InvalidChars', 'csrf'],
12+
'post' => ['invalidchars', 'csrf'],
1313
'get' => ['csrf'],
1414
];
1515

user_guide_src/source/outgoing/view_cells.rst

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@ View Cells
44

55
Many applications have small view fragments that can be repeated from page to page, or in different places on the pages. These are often help boxes, navigation controls, ads, login forms, etc. CodeIgniter lets you encapsulate the logic for these presentation blocks within View Cells. They are basically mini-views that can be included in other views. They can have logic built in to handle any cell-specific display logic. They can be used to make your views more readable and maintainable by separating the logic for each cell into its own class.
66

7-
CodeIgniter supports two types of View Cells: simple and controlled. Simple View Cells can be generated from any class and method of your choice and does not have to follow any rules, except that it must return a string. Controlled View Cells must be generated from a class that extends ``Codeigniter\View\Cells\Cell`` class which provides additional capability making your View Cells more flexible and faster to use.
8-
97
.. contents::
108
:local:
119
:depth: 2
1210

11+
***************************
12+
Simple and Controlled Cells
13+
***************************
14+
15+
CodeIgniter supports two types of View Cells: simple and controlled.
16+
17+
**Simple View Cells** can be generated from any class and method of your choice and does not have to follow any rules, except that it must return a string.
18+
19+
**Controlled View Cells** must be generated from a class that extends ``Codeigniter\View\Cells\Cell`` class which provides additional capability making your View Cells more flexible and faster to use.
20+
1321
.. _app-cells:
1422

1523
*******************
@@ -18,11 +26,13 @@ Calling a View Cell
1826

1927
No matter which type of View Cell you are using, you can call it from any view by using the ``view_cell()`` helper function.
2028

21-
The first parameter is the name of the class and method to call, and the second parameter is an array of parameters to pass to the method:
29+
The first parameter is (1) *the name of the class and method* (Simple Cell) or (2) *the name of the class and optional method* (Controlled Cell) to call,
30+
and the second parameter is an array or string of parameters to pass to the method:
2231

2332
.. literalinclude:: view_cells/001.php
2433

25-
The Cell method must return a string, which will be inserted into the view where the ``view_cell()`` function was called.
34+
The string that the Cell returns will be inserted into the view where the
35+
``view_cell()`` function was called.
2636

2737
Namespace Omission
2838
==================
@@ -67,8 +77,10 @@ Controlled Cells
6777

6878
.. versionadded:: 4.3.0
6979

70-
Controlled cells have two primary goals: to make it as fast as possible to build the cell, and provide additional logic and
71-
flexibility to your views, if they need it. The class must extend ``CodeIgniter\View\Cells\Cell``. They should have a view file
80+
Controlled cells have two primary goals: (1) to make it as fast as possible to build the cell, and (2) provide additional logic and
81+
flexibility to your views, if they need it.
82+
83+
The class must extend ``CodeIgniter\View\Cells\Cell``. They should have a view file
7284
in the same folder. By convention, the class name should be in PascalCase suffixed with ``Cell`` and the view should be
7385
the snake_cased version of the class name, without the suffix. For example, if you have a ``MyCell`` class, the view file
7486
should be ``my.php``.
@@ -79,7 +91,9 @@ should be ``my.php``.
7991
Creating a Controlled Cell
8092
==========================
8193

82-
At the most basic level, all you need to implement within the class are public properties. These properties will be made available to the view file automatically. Implementing the AlertMessage from above as a Controlled Cell would look like this:
94+
At the most basic level, all you need to implement within the class are public properties. These properties will be made available to the view file automatically.
95+
96+
Implementing the AlertMessage from above as a Controlled Cell would look like this:
8397

8498
.. literalinclude:: view_cells/008.php
8599

@@ -108,7 +122,9 @@ You can specify a custom view name by setting the ``view`` property in the class
108122
Customize the Rendering
109123
=======================
110124

111-
If you need more control over the rendering of the HTML, you can implement a ``render()`` method. This method allows you to perform additional logic and pass extra data the view, if needed. The ``render()`` method must return a string. To take advantage of the full features of controlled Cells, you should use ``$this->view()`` instead of the normal ``view()`` helper function:
125+
If you need more control over the rendering of the HTML, you can implement a ``render()`` method. This method allows you to perform additional logic and pass extra data the view, if needed. The ``render()`` method must return a string.
126+
127+
To take advantage of the full features of controlled Cells, you should use ``$this->view()`` instead of the normal ``view()`` helper function:
112128

113129
.. literalinclude:: view_cells/012.php
114130

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
// In a View.
2+
3+
// Simple Cell
24
<?= view_cell('App\Cells\MyClass::myMethod', ['param1' => 'value1', 'param2' => 'value2']) ?>
5+
6+
// Controlled Cell
7+
<?= view_cell('App\Cells\MyCell', ['param1' => 'value1', 'param2' => 'value2']) ?>

user_guide_src/source/outgoing/view_cells/014.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class AlertMessageCell extends Cell
1212
protected $message;
1313
private $computed;
1414

15-
public function mount()
15+
public function mount(): void
1616
{
1717
$this->computed = sprintf('%s - %s', $this->type, $this->message);
1818
}

user_guide_src/source/outgoing/view_cells/016.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class RecentPostsCell extends Cell
1010
{
1111
protected $posts;
1212

13-
public function linkPost($post)
13+
public function linkPost($post): string
1414
{
1515
return anchor('posts/' . $post->id, $post->title);
1616
}

user_guide_src/source/outgoing/view_cells/018.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class RecentPostsCell extends Cell
88
{
99
protected $posts;
1010

11-
public function mount()
11+
public function mount(): void
1212
{
1313
$this->posts = model('PostModel')->orderBy('created_at', 'DESC')->findAll(10);
1414
}

user_guide_src/source/outgoing/view_cells/019.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class RecentPostsCell extends Cell
1010
{
1111
protected $posts;
1212

13-
public function mount(?int $categoryId)
13+
public function mount(?int $categoryId): void
1414
{
1515
$this->posts = model('PostModel')
1616
->when(

0 commit comments

Comments
 (0)