Skip to content

Commit b03f5e5

Browse files
committed
Merge branch '4.x' into 4.next
2 parents 43976d4 + 52d4c9f commit b03f5e5

35 files changed

+1106
-934
lines changed

en/contents.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Contents
8787
Bake <https://book.cakephp.org/bake/2/>
8888
Debug Kit <https://book.cakephp.org/debugkit/4/>
8989
Migrations <https://book.cakephp.org/migrations/3/>
90-
Elasticsearch <https://book.cakephp.org/elasticsearch/2/en/>
90+
Elasticsearch <https://book.cakephp.org/elasticsearch/3/en/>
9191

9292
.. toctree::
9393
:maxdepth: 3

en/controllers/middleware.rst

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ called at the beginning of the request process, you can use the
7575

7676
class Application extends BaseApplication
7777
{
78-
public function middleware(MiddlewareQueue $middlwareQueue): MiddlewareQueue
78+
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
7979
{
8080
// Bind the error handler into the middleware queue.
81-
$middlwareQueue->add(new ErrorHandlerMiddleware());
82-
return $middlwareQueue;
81+
$middlewareQueue->add(new ErrorHandlerMiddleware());
82+
return $middlewareQueue;
8383
}
8484
}
8585

@@ -89,27 +89,27 @@ a variety of operations::
8989
$layer = new \App\Middleware\CustomMiddleware;
9090

9191
// Added middleware will be last in line.
92-
$middlwareQueue->add($layer);
92+
$middlewareQueue->add($layer);
9393

9494
// Prepended middleware will be first in line.
95-
$middlwareQueue->prepend($layer);
95+
$middlewareQueue->prepend($layer);
9696

9797
// Insert in a specific slot. If the slot is out of
9898
// bounds, it will be added to the end.
99-
$middlwareQueue->insertAt(2, $layer);
99+
$middlewareQueue->insertAt(2, $layer);
100100

101101
// Insert before another middleware.
102102
// If the named class cannot be found,
103103
// an exception will be raised.
104-
$middlwareQueue->insertBefore(
104+
$middlewareQueue->insertBefore(
105105
'Cake\Error\Middleware\ErrorHandlerMiddleware',
106106
$layer
107107
);
108108

109109
// Insert after another middleware.
110110
// If the named class cannot be found, the
111111
// middleware will added to the end.
112-
$middlwareQueue->insertAfter(
112+
$middlewareQueue->insertAfter(
113113
'Cake\Error\Middleware\ErrorHandlerMiddleware',
114114
$layer
115115
);
@@ -133,11 +133,11 @@ have to the application's middleware queue::
133133

134134
class Plugin extends BasePlugin
135135
{
136-
public function middleware(MiddlewareQueue $middlwareQueue): MiddlewareQueue
136+
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
137137
{
138-
$middlwareQueue->add(new ContactManagerContextMiddleware());
138+
$middlewareQueue->add(new ContactManagerContextMiddleware());
139139

140-
return $middlwareQueue;
140+
return $middlewareQueue;
141141
}
142142
}
143143

@@ -203,14 +203,14 @@ application::
203203

204204
class Application
205205
{
206-
public function middleware(MiddlewareQueue $middlwareQueue): MiddlewareQueue
206+
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
207207
{
208208
// Add your simple middleware onto the queue
209-
$middlwareQueue->add(new TrackingCookieMiddleware());
209+
$middlewareQueue->add(new TrackingCookieMiddleware());
210210

211211
// Add some more middleware onto the queue
212212

213-
return $middlwareQueue;
213+
return $middlewareQueue;
214214
}
215215
}
216216

@@ -227,10 +227,10 @@ enable cached routes, provide the desired :ref:`cache configuration
227227
<cache-configuration>` as a parameter::
228228

229229
// In Application.php
230-
public function middleware(MiddlewareQueue $middlwareQueue): MiddlewareQueue
230+
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
231231
{
232232
// ...
233-
$middlwareQueue->add(new RoutingMiddleware($this, 'routing'));
233+
$middlewareQueue->add(new RoutingMiddleware($this, 'routing'));
234234
}
235235

236236
The above would use the ``routing`` cache engine to store the generated route
@@ -313,7 +313,7 @@ Cookie data is encrypted with via OpenSSL using AES::
313313
Configure::read('Security.cookieKey')
314314
);
315315

316-
$middlwareQueue->add($cookies);
316+
$middlewareQueue->add($cookies);
317317

318318
.. note::
319319
It is recommended that the encryption key you use for cookie data, is used
@@ -341,14 +341,15 @@ stack you protect all the actions in application::
341341
// in src/Application.php
342342
use Cake\Http\Middleware\CsrfProtectionMiddleware;
343343

344-
public function middleware($middlwareQueue) {
344+
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
345+
{
345346
$options = [
346347
// ...
347348
];
348349
$csrf = new CsrfProtectionMiddleware($options);
349350

350-
$middlwareQueue->add($csrf);
351-
return $middlwareQueue;
351+
$middlewareQueue->add($csrf);
352+
return $middlewareQueue;
352353
}
353354

354355
By applying the ``CsrfProtectionMiddleware`` to routing scopes, you can include
@@ -357,7 +358,8 @@ or exclude specific route groups::
357358
// in src/Application.php
358359
use Cake\Http\Middleware\CsrfProtectionMiddleware;
359360

360-
public function routes($routes) {
361+
public function routes(RouteBuilder $routes) : void
362+
{
361363
$options = [
362364
// ...
363365
];
@@ -393,7 +395,8 @@ URLs for which CSRF token check should be done::
393395
// in src/Application.php
394396
use Cake\Http\Middleware\CsrfProtectionMiddleware;
395397

396-
public function middleware($middlewareQueue) {
398+
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
399+
{
397400
$csrf = new CsrfProtectionMiddleware();
398401

399402
// Token check will be skipped when callback returns `true`.
@@ -517,7 +520,7 @@ use the ``HttpsEnforcerMiddleware``::
517520

518521
// Send additional headers in the redirect response.
519522
$https = new HttpsEnforcerMiddleware([
520-
'headers' => ['X-Https-Upgrade', => true],
523+
'headers' => ['X-Https-Upgrade' => true],
521524
]);
522525

523526
// Disable HTTPs enforcement when ``debug`` is on.

en/controllers/request-response.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ For non-existent names the ``$default`` value will be returned::
115115
You can also use :ref:`body-parser-middleware` to parse request body of different
116116
content types into an array, so that it's accessible through ``ServerRequest::getData()``.
117117

118+
If you want to access all the data parameters you can use
119+
``getParsedBody()``::
120+
121+
$data = $this->request->getParsedBody();
122+
118123
.. _request-file-uploads:
119124

120125
File Uploads
@@ -126,11 +131,6 @@ be accessed like this::
126131

127132
$attachment = $this->request->getData('attachment');
128133

129-
By default file uploads are represented in the request data as objects that implement
130-
`\\Psr\\Http\\Message\\UploadedFileInterface <https://www.php-fig.org/psr/psr-7/#16-uploaded-files>`__.
131-
In the above example, ``$attachment`` would hold an object, in the current implementation it would by default be an
132-
instance of ``\Zend\Diactoros\UploadedFile``.
133-
134134
By default file uploads are represented in the request data as objects that implement
135135
`\\Psr\\Http\\Message\\UploadedFileInterface <https://www.php-fig.org/psr/psr-7/#16-uploaded-files>`__. In the current
136136
implementation, the ``$attachment`` variable in the above example would by default hold an instance of
@@ -205,7 +205,7 @@ Returns all uploaded files in a normalized array structure. For the above exampl
205205
``attachment``, the structure would look like::
206206

207207
[
208-
'attachment' => object(Zend\Diactoros\UploadedFile) {
208+
'attachment' => object(Laminas\Diactoros\UploadedFile) {
209209
// ...
210210
}
211211
]
@@ -791,17 +791,17 @@ To set a string as the response body, do the following::
791791
.. php:method:: withBody($body)
792792
793793
To set the response body, use the ``withBody()`` method, which is provided by the
794-
:php:class:`Zend\\Diactoros\\MessageTrait`::
794+
:php:class:`Laminas\\Diactoros\\MessageTrait`::
795795

796796
$response = $response->withBody($stream);
797797

798798
Be sure that ``$stream`` is a :php:class:`Psr\\Http\\Message\\StreamInterface` object.
799799
See below on how to create a new stream.
800800

801-
You can also stream responses from files using :php:class:`Zend\\Diactoros\\Stream` streams::
801+
You can also stream responses from files using :php:class:`Laminas\\Diactoros\\Stream` streams::
802802

803803
// To stream from a file
804-
use Zend\Diactoros\Stream;
804+
use Laminas\Diactoros\Stream;
805805

806806
$stream = new Stream('/path/to/file', 'rb');
807807
$response = $response->withBody($stream);

en/core-libraries/email.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ following configuration keys are used:
101101
- ``'bcc'``: Mailer or array of blind carbon copy. See ``Mailer::setBcc()``.
102102
- ``'replyTo'``: Mailer or array to reply the e-mail. See ``Mailer::setReplyTo()``.
103103
- ``'readReceipt'``: Mailer address or an array of addresses to receive the
104-
receipt of read. See ``Mailer::readReceipt()``.
104+
receipt of read. See ``Mailer::setReadReceipt()``.
105105
- ``'returnPath'``: Mailer address or an array of addresses to return if have
106106
some error. See ``Mailer::setReturnPath()``.
107107
- ``'messageId'``: Message ID of e-mail. See ``Mailer::setMessageId()``.
@@ -187,7 +187,7 @@ This would use the following template files:
187187
When sending templated emails you have the option of sending either
188188
``text``, ``html`` or ``both``.
189189

190-
You can set all view related config using the view bulder instance got by
190+
You can set all view related config using the view builder instance got by
191191
``Mailer::viewBuilder()`` similar to how you do the same in controller.
192192

193193
You can set view variables with ``Mailer::setViewVars()``::

en/development/configuration.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ configurations allowing you to easily vary these libraries in each environment.
6262

6363
For local development, CakePHP leverages `dotenv
6464
<https://github.com/josegonzalez/php-dotenv>`_ to allow easy local development using
65-
environment variables. You will see a ``config/.env.example`` in your
65+
environment variables. Use composer to require this library and then
66+
there is a block of code in ``bootstrap.php`` that needs to be uncommented to harness it.
67+
68+
You will see a ``config/.env.example`` in your
6669
application. By copying this file into ``config/.env`` and customizing the
6770
values you can configure your application.
71+
6872

6973
You should avoid committing the ``config/.env`` file to your repository and
7074
instead use the ``config/.env.example`` as a template with placeholder values so

en/elasticsearch.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
ElasticSearch
22
#############
33

4-
This page has `moved <https://book.cakephp.org/elasticsearch/2.x/en/>`__.
4+
This page has `moved <https://book.cakephp.org/elasticsearch/3/en/>`__.

0 commit comments

Comments
 (0)