Skip to content

Commit bfb10bc

Browse files
committed
Merge branch '5.x' into 5.next
2 parents f69f99a + 7da5902 commit bfb10bc

File tree

20 files changed

+83
-68
lines changed

20 files changed

+83
-68
lines changed

en/controllers/components/form-protection.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
FormProtection
2-
##############
1+
Form Protection Component
2+
#########################
33

44
.. php:class:: FormProtection(ComponentCollection $collection, array $config = [])
55

en/controllers/pagination.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ You can also use :ref:`custom-find-methods` in pagination by using the ``finder`
6262
];
6363
}
6464

65+
Note: This only works with Table as string input in ``$this->paginate('MyTable')``. Once you use ``$this->MyTable->find()`` as input for ``paginate()``, you must directly use that Query object instead.
66+
6567
If your finder method requires additional options you can pass those
6668
as values for the finder::
6769

en/controllers/request-response.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,22 +273,26 @@ types making the parsed data available in ``$request->getData()`` and
273273
Environment Variables (from $_SERVER and $_ENV)
274274
-----------------------------------------------
275275

276-
.. php:method:: putenv($key, $value = null)
276+
.. php:method:: getEnv($key, $default = null)
277277
278278
``ServerRequest::getEnv()`` is a wrapper for ``getenv()`` global function and acts as
279-
a getter/setter for environment variables without having to modify globals
280-
``$_SERVER`` and ``$_ENV``::
279+
a getter for environment variables without possible undefined keys::
281280

282-
// Get the host
283281
$host = $this->request->getEnv('HTTP_HOST');
284282

285-
// Set a value, generally helpful in testing.
286-
$this->request->withEnv('REQUEST_METHOD', 'POST');
287-
288283
To access all the environment variables in a request use ``getServerParams()``::
289284

290285
$env = $this->request->getServerParams();
291286

287+
.. php:method:: withEnv($key, $value)
288+
289+
``ServerRequest::withEnv()`` is a wrapper for ``putenv()`` global function and acts as
290+
a setter for environment variables without having to modify globals
291+
``$_SERVER`` and ``$_ENV``::
292+
293+
// Set a value, generally helpful in testing.
294+
$this->request->withEnv('REQUEST_METHOD', 'POST');
295+
292296
XML or JSON Data
293297
----------------
294298

en/development/dependency-injection.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,13 @@ Command Example
5555
::
5656

5757
// In src/Command/CheckUsersCommand.php
58+
use Cake\Console\CommandFactoryInterface;
59+
5860
class CheckUsersCommand extends Command
5961
{
60-
public function __construct(public UsersService $users)
62+
public function __construct(protected UsersService $users, ?CommandFactoryInterface $factory = null)
6163
{
64+
parent::__construct($factory);
6265
}
6366

6467
public function execute(Arguments $args, ConsoleIo $io)
@@ -73,7 +76,8 @@ Command Example
7376
{
7477
$container
7578
->add(CheckUsersCommand::class)
76-
->addArgument(UsersService::class);
79+
->addArgument(UsersService::class)
80+
->addArgument(CommandFactoryInterface::class);
7781
$container->add(UsersService::class);
7882
}
7983

@@ -89,13 +93,14 @@ Component Example
8993
::
9094

9195
// In src/Controller/Component/SearchComponent.php
92-
class SearchComponent extends Command
96+
class SearchComponent extends Component
9397
{
9498
public function __construct(
9599
ComponentRegistry $registry,
96-
private UserService $users
100+
private UserService $users,
101+
array $config = []
97102
) {
98-
parent::__construct($registry, []);
103+
parent::__construct($registry, $config);
99104
}
100105

101106
public function something()

en/development/errors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ provide more context around your errors::
354354

355355
use Cake\Core\Exception\CakeException;
356356

357-
class MissingWidgetException extends Exception
357+
class MissingWidgetException extends CakeException
358358
{
359359
// Context data is interpolated into this format string.
360360
protected $_messageTemplate = 'Seems that %s is missing.';

en/development/routing.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ will be treated as part of the parameter::
295295

296296
The above example illustrates how to create a quick way to view
297297
models from any controller by crafting a URL that looks like
298-
``/controllername/{id}``. The URL provided to ``connect()`` specifies two
298+
``/controller-name/{id}``. The URL provided to ``connect()`` specifies two
299299
route elements: ``{controller}`` and ``{id}``. The ``{controller}`` element
300300
is a CakePHP default route element, so the router knows how to match and
301301
identify controller names in URLs. The ``{id}`` element is a custom
@@ -712,7 +712,7 @@ When using nesting, you need to chain them together::
712712
['prefix' => 'Admin/MyPrefix', 'controller' => 'TodoItems', 'action' => 'create']
713713
);
714714

715-
This would link to a controller with the namespace ``App\\Controller\\Admin\\MyPrefix`` and the file path
715+
This would link to a controller with the namespace ``App\Controller\Admin\MyPrefix`` and the file path
716716
``src/Controller/Admin/MyPrefix/TodoItemsController.php``.
717717

718718
.. note::
@@ -1579,7 +1579,7 @@ Custom Route Classes
15791579
Custom route classes allow you to extend and change how individual routes parse
15801580
requests and handle reverse routing. Route classes have a few conventions:
15811581

1582-
* Route classes are expected to be found in the ``Routing\\Route`` namespace of
1582+
* Route classes are expected to be found in the ``Routing\Route`` namespace of
15831583
your application or plugin.
15841584
* Route classes should extend :php:class:`\\Cake\\Routing\\Route\\Route`.
15851585
* Route classes should implement one or both of ``match()`` and/or ``parse()``.

en/orm/database-basics.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,14 @@ Enum Type
476476
Maps a `BackedEnum <https://www.php.net/manual/en/language.enumerations.backed.php>`_ to a string or integer column.
477477
To use this type you need to specify which column is associated to which BackedEnum inside the table class::
478478

479-
use \Cake\Database\Type\EnumType;
480-
use \App\Model\Enum\ArticleStatus;
479+
use App\Model\Enum\ArticleStatus;
480+
use Cake\Database\Type\EnumType;
481481

482482
// in src/Model/Table/ArticlesTable.php
483483
public function initialize(array $config): void
484484
{
485+
parent::initialize($config);
486+
485487
$this->getSchema()->setColumnType('status', EnumType::from(ArticleStatus::class));
486488
}
487489

@@ -599,14 +601,16 @@ We then have two ways to use our datatype in our models.
599601

600602
Overwriting the reflected schema with our custom type will enable CakePHP's
601603
database layer to automatically convert JSON data when creating queries. In your
602-
Table's :ref:`getSchema() method <saving-complex-types>` add the
604+
Table's :ref:`initialize() method <saving-complex-types>` add the
603605
following::
604606

605607
class WidgetsTable extends Table
606608
{
607-
public function getSchema(): TableSchemaInterface
609+
public function initialize(array $config): void
608610
{
609-
return parent::getSchema()->setColumnType('widget_prefs', 'json');
611+
parent::initialize($config);
612+
613+
$this->getSchema()->setColumnType('widget_prefs', 'json');
610614
}
611615
}
612616

en/orm/query-builder.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ You can also get a key-value list out of a query result::
150150
For more information on how to customize the fields used for populating the list
151151
refer to :ref:`table-find-list` section.
152152

153-
Resultset Are Collection Objects
153+
ResultSet Is A Collection Object
154154
--------------------------------
155155

156156
Once you get familiar with the Query object methods, it is strongly encouraged
157157
that you visit the :doc:`Collection </core-libraries/collections>` section to
158-
improve your skills in efficiently traversing the results. The resultset (returned
158+
improve your skills in efficiently traversing the results. The ResultSet (returned
159159
by calling the ``SelectQuery``'s ``all()`` method) implements the collection interface::
160160

161161
// Use the combine() method from the collections library

en/orm/saving-data.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,12 +1094,11 @@ column Types::
10941094

10951095
class UsersTable extends Table
10961096
{
1097-
public function getSchema(): TableSchemaInterface
1097+
public function initialize(array $config): void
10981098
{
1099-
$schema = parent::getSchema();
1100-
$schema->setColumnType('preferences', 'json');
1099+
parent::initialize($config);
11011100

1102-
return $schema;
1101+
$this->getSchema()->setColumnType('preferences', 'json');
11031102
}
11041103
}
11051104

en/quickstart.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ To start off we'll build a simple Content Management application.
66

77
.. include:: /tutorials-and-examples/cms/installation.rst
88
.. include:: /tutorials-and-examples/cms/database.rst
9+
.. include:: /tutorials-and-examples/cms/articles-model.rst
910
.. include:: /tutorials-and-examples/cms/articles-controller.rst
1011

1112
.. meta::

0 commit comments

Comments
 (0)