Skip to content

Commit f58f33d

Browse files
committed
Merge branch '5.x' into 5.next
2 parents 340a585 + d27314b commit f58f33d

4 files changed

Lines changed: 43 additions & 42 deletions

File tree

docs/en/contributing/documentation.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -453,16 +453,16 @@ You can use `npx` to run the tools without installing them globally, or install
453453
```bash [Using npx (Recommended)]
454454
# No installation needed - npx downloads and runs the tools
455455
npx cspell --config .github/cspell.json "docs/en/**/*.md"
456-
npx markdownlint-cli --config .github/markdownlint.json "docs/en/**/*.md"
456+
npx markdownlint-cli2 --config .github/.markdownlint-cli2.jsonc "docs/en/**/*.md"
457457
```
458458

459459
```bash [Global Installation]
460460
# Install globally for faster execution
461-
npm install -g cspell markdownlint-cli
461+
npm install -g cspell markdownlint-cli2
462462

463463
# Then run without npx
464464
cspell --config .github/cspell.json "docs/en/**/*.md"
465-
markdownlint-cli --config .github/markdownlint.json "docs/en/**/*.md"
465+
markdownlint-cli2 --config .github/.markdownlint-cli2.jsonc "docs/en/**/*.md"
466466
```
467467

468468
:::
@@ -496,28 +496,30 @@ If cspell flags legitimate technical terms (class names, CakePHP-specific terms)
496496

497497
### Running Markdown Lint
498498

499-
We use [markdownlint](https://github.com/DavidAnson/markdownlint) to maintain consistent markdown formatting:
499+
We use [markdownlint](https://github.com/DavidAnson/markdownlint) via
500+
[markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2) to maintain
501+
consistent markdown formatting:
500502

501503
::: code-group
502504

503505
```bash [Single File]
504506
# Check a single file
505-
npx markdownlint-cli --config .github/markdownlint.json docs/en/your-file.md
507+
npx markdownlint-cli2 --config .github/.markdownlint-cli2.jsonc docs/en/your-file.md
506508
```
507509

508510
```bash [Directory]
509511
# Check all files in a directory
510-
npx markdownlint-cli --config .github/markdownlint.json "docs/en/controllers/*.md"
512+
npx markdownlint-cli2 --config .github/.markdownlint-cli2.jsonc "docs/en/controllers/*.md"
511513
```
512514

513515
```bash [All Docs]
514516
# Check all English documentation
515-
npx markdownlint-cli --config .github/markdownlint.json "docs/en/**/*.md"
517+
npx markdownlint-cli2 --config .github/.markdownlint-cli2.jsonc "docs/en/**/*.md"
516518
```
517519

518520
```bash [Auto-fix]
519521
# Automatically fix formatting issues
520-
npx markdownlint-cli --config .github/markdownlint.json --fix "docs/en/**/*.md"
522+
npx markdownlint-cli2 --config .github/.markdownlint-cli2.jsonc --fix "docs/en/**/*.md"
521523
```
522524

523525
:::
@@ -583,14 +585,14 @@ When you submit a pull request, our CI pipeline automatically runs:
583585

584586
```bash [Quick Check]
585587
# Validate markdown and spelling
586-
npx markdownlint-cli --config .github/markdownlint.json "docs/**/*.md"
588+
npx markdownlint-cli2 --config .github/.markdownlint-cli2.jsonc "docs/**/*.md"
587589
npx cspell --config .github/cspell.json "docs/**/*.md"
588590
node bin/check-links.js "docs/**/*.md"
589591
```
590592

591593
```bash [Full Validation]
592594
# Run all CI checks locally
593-
npx markdownlint-cli --config .github/markdownlint.json "docs/**/*.md"
595+
npx markdownlint-cli2 --config .github/.markdownlint-cli2.jsonc "docs/**/*.md"
594596
npx cspell --config .github/cspell.json "docs/**/*.md"
595597
node bin/check-links.js "docs/**/*.md"
596598
node --check config.js
@@ -599,7 +601,7 @@ jq empty toc_en.json
599601

600602
```bash [Single File]
601603
# Check your current file before committing
602-
npx markdownlint-cli --config .github/markdownlint.json docs/en/your-file.md
604+
npx markdownlint-cli2 --config .github/.markdownlint-cli2.jsonc docs/en/your-file.md
603605
npx cspell --config .github/cspell.json docs/en/your-file.md
604606
node bin/check-links.js docs/en/your-file.md
605607
```

docs/en/orm/associations.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,8 @@ Possible keys for hasMany association arrays include:
465465
- **strategy**: Defines the query strategy to use. Defaults to 'select'. The
466466
other valid value is 'subquery', which replaces the `IN` list with an
467467
equivalent subquery.
468-
- **saveStrategy**: Either 'append' or 'replace'. Defaults to 'append'. When 'append' the current
469-
records are appended to any records in the database. When 'replace' associated
468+
- **saveStrategy**: Either `append` or `replace`. Defaults to `append`. When `append` the current
469+
records are appended to any records in the database. When `replace` associated
470470
records not in the current set will be removed. If the foreign key is a nullable
471471
column or if `dependent` is true records will be orphaned.
472472
- **finder**: The finder method to use when loading associated records. See the
@@ -619,7 +619,7 @@ Possible keys for belongsToMany association arrays include:
619619
- **strategy**: Defines the query strategy to use. Defaults to 'select'. The
620620
other valid value is 'subquery', which replaces the `IN` list with an
621621
equivalent subquery.
622-
- **saveStrategy**: Either 'append' or 'replace'. Defaults to 'replace'.
622+
- **saveStrategy**: Either `append` or `replace`. Defaults to `replace`.
623623
Indicates the mode to be used for saving associated entities. The former will
624624
only create new links between both side of the relation and the latter will
625625
do a wipe and replace to create the links between the passed entities when

docs/en/tutorials-and-examples/cms/authentication.md

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enable new users to register.
1616
Use composer to install the Authentication Plugin:
1717

1818
```bash
19-
composer require "cakephp/authentication:~4.0"
19+
composer require "cakephp/authentication:^4.0"
2020
```
2121

2222
## Adding Password Hashing
@@ -45,7 +45,7 @@ Because we want to hash the password each time it is set, we'll use a mutator/se
4545
CakePHP will call a convention based setter method any time a property is set in one of your
4646
entities. Let's add a setter for the password in **src/Model/Entity/User.php**:
4747

48-
```php {3,12-18}
48+
```php {4,12-18}
4949
<?php
5050
namespace App\Model\Entity;
5151

@@ -109,7 +109,7 @@ In **src/Application.php**, add the following imports:
109109
use Authentication\AuthenticationService;
110110
use Authentication\AuthenticationServiceInterface;
111111
use Authentication\AuthenticationServiceProviderInterface;
112-
use Authentication\Identifier\AbstractIdentifier;
112+
use Authentication\Identifier\PasswordIdentifier;
113113
use Authentication\Middleware\AuthenticationMiddleware;
114114
use Psr\Http\Message\ServerRequestInterface;
115115
```
@@ -123,11 +123,9 @@ class Application extends BaseApplication
123123
{
124124
```
125125

126-
Then add the following methods:
126+
Then add the following to your `middleware()` method:
127127

128-
::: code-group
129-
130-
```php [middleware()]
128+
```php
131129
// src/Application.php
132130
public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
133131
{
@@ -142,7 +140,9 @@ public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
142140
}
143141
```
144142

145-
```php [getAuthenticationService()]
143+
Next, add the `getAuthenticationService()` method:
144+
145+
```php
146146
// src/Application.php
147147
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
148148
{
@@ -160,8 +160,8 @@ public function getAuthenticationService(ServerRequestInterface $request): Authe
160160
]);
161161

162162
$fields = [
163-
AbstractIdentifier::CREDENTIAL_USERNAME => 'email',
164-
AbstractIdentifier::CREDENTIAL_PASSWORD => 'password',
163+
PasswordIdentifier::CREDENTIAL_USERNAME => 'email',
164+
PasswordIdentifier::CREDENTIAL_PASSWORD => 'password',
165165
];
166166

167167
// Load the authenticators. Session should be first.
@@ -175,23 +175,20 @@ public function getAuthenticationService(ServerRequestInterface $request): Authe
175175
'action' => 'login',
176176
],
177177
'identifier' => [
178-
'Authentication.Password' => [
179-
'fields' => $fields,
180-
],
178+
'className' => 'Authentication.Password',
179+
'fields' => $fields,
181180
],
182181
]);
183182

184183
return $service;
185184
}
186185
```
187186

188-
:::
189-
190187
### Configuring the AppController
191188

192189
In your `AppController` class add the following code:
193190

194-
```php {7}
191+
```php {8}
195192
// src/Controller/AppController.php
196193
public function initialize(): void
197194
{
@@ -232,9 +229,8 @@ If you visit your site, you'll get an "infinite redirect loop" so let's fix that
232229

233230
In your `UsersController`, add the following code:
234231

235-
::: code-group
236-
237-
```php [UsersController.php]
232+
```php
233+
// src/Controller/UsersController.php
238234
public function beforeFilter(\Cake\Event\EventInterface $event): void
239235
{
240236
parent::beforeFilter($event);
@@ -260,7 +256,10 @@ public function login()
260256
}
261257
```
262258

263-
```php [templates/Users/login.php]
259+
Next, add the template for your login action:
260+
261+
```php
262+
<!-- templates/Users/login.php -->
264263
<div class="users form content">
265264
<?= $this->Flash->render() ?>
266265
<h3>Login</h3>
@@ -277,8 +276,6 @@ public function login()
277276
</div>
278277
```
279278

280-
:::
281-
282279
Now the login page will allow us to correctly login into the application.
283280
Test it by requesting any page of your site. After being redirected
284281
to the `/users/login` page, enter the email and password you
@@ -291,7 +288,7 @@ We need to add a couple more details to configure our application.
291288
We want all `view` and `index` pages accessible without logging in so we'll add this specific
292289
configuration in AppController:
293290

294-
```php {6}
291+
```php {7}
295292
// in src/Controller/AppController.php
296293
public function beforeFilter(\Cake\Event\EventInterface $event): void
297294
{
@@ -336,7 +333,7 @@ If you try to visit **/users/add** without being logged in, you will be
336333
redirected to the login page. We should fix that as we want to allow people to
337334
sign up for our application. In the `UsersController` update the `beforeFilter`:
338335

339-
```php {3}
336+
```php {2}
340337
// In UsersController::beforeFilter()
341338
$this->Authentication->allowUnauthenticated(['login', 'add']);
342339
```

docs/en/tutorials-and-examples/cms/authorization.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: "Implement authorization in CakePHP CMS with policy classes. Contro
77

88
With users now able to login to our CMS, we want to apply authorization rules
99
to ensure that each user only edits the posts they own. We'll use the
10-
[authorization plugin](https://book.cakephp.org/authorization/2) to do this.
10+
[authorization plugin](https://book.cakephp.org/authorization/3) to do this.
1111

1212
## Installing Authorization Plugin
1313

@@ -40,9 +40,11 @@ use Authorization\Policy\OrmResolver;
4040

4141
Add the `AuthorizationServiceProviderInterface` to the implemented interfaces on your application:
4242

43-
class Application extends BaseApplication
44-
implements AuthenticationServiceProviderInterface,
45-
AuthorizationServiceProviderInterface
43+
```php {2-3}
44+
class Application extends BaseApplication
45+
implements AuthenticationServiceProviderInterface,
46+
AuthorizationServiceProviderInterface
47+
```
4648

4749
Then add the following to your `middleware()` method:
4850

0 commit comments

Comments
 (0)