Skip to content

Commit 247d05e

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.4
2 parents 20b3a75 + 0b2674f commit 247d05e

34 files changed

+233
-109
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"phpunit/phpcov": "^8.2",
2525
"phpunit/phpunit": "^9.1",
2626
"predis/predis": "^1.1 || ^2.0",
27-
"rector/rector": "0.17.2",
27+
"rector/rector": "0.17.3",
2828
"vimeo/psalm": "^5.0"
2929
},
3030
"suggest": {

user_guide_src/source/general/configuration.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,25 @@ Registrars
281281

282282
"Registrars" are any other classes which might provide additional configuration properties.
283283
Registrars provide a means of altering a configuration at runtime across namespaces and files.
284-
There are two ways to implement a Registrar: implicit and explicit.
284+
285+
Registrars work if :ref:`auto-discovery` is enabled in :doc:`Modules </general/modules>`.
286+
It alters configuration properties when the Config object is instantiated.
287+
288+
There are two ways to implement a Registrar: **implicit** and **explicit**.
285289

286290
.. note:: Values from **.env** always take priority over Registrars.
287291

288292
Implicit Registrars
289293
===================
290294

291-
Any namespace may define registrars by using the **Config/Registrar.php** file, if discovery
292-
is enabled in :doc:`Modules </general/modules>`. These files are classes whose methods are
293-
named for each configuration class you wish to extend. For example, a third-party module might
294-
wish to supply an additional template to ``Pager`` without overwriting whatever a develop has
295+
Implicit Registrars can change any Config class properties.
296+
297+
Any namespace may define implicit registrars by using the **Config/Registrar.php**
298+
file. These files are classes whose methods are named for each configuration class
299+
you wish to extend.
300+
301+
For example, a third-party module or Composer package might
302+
wish to supply an additional template to ``Config\Pager`` without overwriting whatever a developer has
295303
already configured. In **src/Config/Registrar.php** there would be a ``Registrar`` class with
296304
the single ``Pager()`` method (note the case-sensitivity):
297305

@@ -304,6 +312,9 @@ overwrite priority.
304312
Explicit Registrars
305313
===================
306314

315+
Explicit Registrars can only change the Config class properties in which they are
316+
registered.
317+
307318
A configuration file can also specify any number of registrars explicitly.
308319
This is done by adding a ``$registrars`` property to your configuration file,
309320
holding an array of the names of candidate registrars:

user_guide_src/source/general/configuration/007.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace CodeIgniter\Shield\Config;
4+
35
class Registrar
46
{
57
public static function Pager(): array

user_guide_src/source/general/configuration/008.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Config;
44

5+
// ...
6+
57
class MyConfig extends BaseConfig
68
{
79
public static $registrars = [

user_guide_src/source/general/configuration/009.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
class MySalesConfig extends BaseConfig
88
{
9-
public $target = 100;
10-
public $campaign = 'Winter Wonderland';
9+
public int $target = 100;
10+
public string $campaign = 'Winter Wonderland';
1111
public static $registrars = [
1212
'\App\Models\RegionalSales',
1313
];

user_guide_src/source/general/configuration/010.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class RegionalSales
66
{
7-
public static function MySalesConfig()
7+
public static function MySalesConfig(): array
88
{
99
return [
1010
'target' => 45,

user_guide_src/source/general/modules.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ language files, etc. Modules may contain as few, or as many, of these as you lik
1111
:local:
1212
:depth: 2
1313

14-
==========
14+
**********
1515
Namespaces
16-
==========
16+
**********
1717

1818
The core element of the modules functionality comes from the :doc:`PSR-4 compatible autoloading <../concepts/autoloader>`
1919
that CodeIgniter uses. While any code can use the PSR-4 autoloader and namespaces, the primary way to take full advantage of
@@ -58,9 +58,9 @@ Of course, there is nothing forcing you to use this exact structure, and you sho
5858
best suits your module, leaving out directories you don't need, creating new directories for Entities, Interfaces,
5959
or Repositories, etc.
6060

61-
===========================
61+
***************************
6262
Autoloading Non-class Files
63-
===========================
63+
***************************
6464

6565
More often than not that your module will not contain only PHP classes but also others like procedural
6666
functions, bootstrapping files, module constants files, etc. which are not normally loaded the way classes
@@ -73,31 +73,33 @@ your classes. All we need to do is provide the list of paths to those files and
7373

7474
.. literalinclude:: modules/002.php
7575

76-
==============
76+
.. _auto-discovery:
77+
78+
**************
7779
Auto-Discovery
78-
==============
80+
**************
7981

8082
Many times, you will need to specify the full namespace to files you want to include, but CodeIgniter can be
8183
configured to make integrating modules into your applications simpler by automatically discovering many different
8284
file types, including:
8385

8486
- :doc:`Events <../extending/events>`
8587
- :doc:`Filters <../incoming/filters>`
86-
- :doc:`Registrars <./configuration>`
88+
- :ref:`registrars`
8789
- :doc:`Route files <../incoming/routing>`
8890
- :doc:`Services <../concepts/services>`
8991

9092
This is configured in the file **app/Config/Modules.php**.
9193

92-
The auto-discovery system works by scanning for particular directories and files within psr4 namespaces that have been defined in **Config/Autoload.php**.
94+
The auto-discovery system works by scanning for particular directories and files within psr4 namespaces that have been defined in **Config/Autoload.php** and Composer packages.
9395

94-
The discovery process would look for discoverable items on that path and should, for example, find the routes file at **/acme/Blog/Config/Routes.php**.
96+
The discovery process would look for discoverable items on that path and should, for example, find the routes file at **acme/Blog/Config/Routes.php**.
9597

9698
Enable/Disable Discover
9799
=======================
98100

99101
You can turn on or off all auto-discovery in the system with the ``$enabled`` class variable. False will disable
100-
all discovery, optimizing performance, but negating the special capabilities of your modules.
102+
all discovery, optimizing performance, but negating the special capabilities of your modules and Composer packages.
101103

102104
Specify Discovery Items
103105
=======================
@@ -134,9 +136,9 @@ by editing the ``$discoverInComposer`` variable in **app/Config/Modules.php**:
134136

135137
.. literalinclude:: modules/004.php
136138

137-
==================
139+
******************
138140
Working with Files
139-
==================
141+
******************
140142

141143
This section will take a look at each of the file types (controllers, views, language files, etc) and how they can
142144
be used within the module. Some of this information is described in more detail in the relevant location of the user

user_guide_src/source/helpers/form_helper.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,10 @@ The following functions are available:
536536
The returned array is the same as ``Validation::getErrors()``.
537537
See :ref:`Validation <validation-redirect-and-validation-errors>` for details.
538538

539+
.. note:: This function does not work with :ref:`in-model-validation`. If you
540+
want to get the validation errors in model validation, see
541+
:ref:`model-getting-validation-errors`.
542+
539543
Example::
540544

541545
<?php $errors = validation_errors(); ?>
@@ -555,6 +559,10 @@ The following functions are available:
555559

556560
This function uses :php:func:`validation_errors()` internally.
557561

562+
.. note:: This function does not work with :ref:`in-model-validation`. If you
563+
want to get the validation errors in model validation, see
564+
:ref:`model-getting-validation-errors`.
565+
558566
Example::
559567

560568
<?= validation_list_errors() ?>
@@ -575,6 +583,10 @@ The following functions are available:
575583

576584
This function uses :php:func:`validation_errors()` internally.
577585

586+
.. note:: This function does not work with :ref:`in-model-validation`. If you
587+
want to get the validation errors in model validation, see
588+
:ref:`model-getting-validation-errors`.
589+
578590
Example::
579591

580592
<?= validation_show_error('username') ?>

user_guide_src/source/installation/upgrade_435.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@ Breaking Changes
1818
Validation Placeholders
1919
=======================
2020

21-
- To use :ref:`validation-placeholders` securely, please remember to create a validation rule for the field you will use as a placeholder.
21+
To use :ref:`validation-placeholders` securely, please remember to create a validation rule for the field you will use as a placeholder.
22+
23+
E.g., if you have the following code::
24+
25+
$validation->setRules([
26+
'email' => 'required|max_length[254]|valid_email|is_unique[users.email,id,{id}]',
27+
]);
28+
29+
You need to add the rules for ``{id}``::
30+
31+
$validation->setRules([
32+
'id' => 'max_length[19]|is_natural_no_zero', // Add this
33+
'email' => 'required|max_length[254]|valid_email|is_unique[users.email,id,{id}]',
34+
]);
2235

2336
Session::stop()
2437
===============

user_guide_src/source/libraries/validation/002.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// ...
44

55
$rules = [
6-
'username' => 'required',
7-
'password' => 'required|min_length[10]',
8-
'passconf' => 'required|matches[password]',
9-
'email' => 'required|valid_email',
6+
'username' => 'required|max_length[30]',
7+
'password' => 'required|max_length[255]|min_length[10]',
8+
'passconf' => 'required|max_length[255]|matches[password]',
9+
'email' => 'required|max_length[254]|valid_email',
1010
];
1111

1212
// ...

0 commit comments

Comments
 (0)