Skip to content

Commit 414df09

Browse files
committed
docs: add page title to code blocks
1 parent 4a07091 commit 414df09

34 files changed

+562
-324
lines changed

docs/admin-ui/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ You can install the optional [BootstrapAdminUi package](../bootstrap-admin-ui/ge
3535

3636
*Usage with Sylius Resource package*
3737

38+
{% code title="src/Entity/Speaker.php" lineNumbers="true" %}
3839
```php
39-
// src/Entity/Speaker.php
40-
4140
namespace App\Entity;
4241

4342
use Sylius\Resource\Metadata\AsResource;
@@ -52,6 +51,7 @@ class Speaker implements ResourceInterface
5251
}
5352

5453
```
54+
{% endcode %}
5555

5656
### Dashboard
5757

docs/cookbook/admin_panel/page_titles.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ We're going to reuse this hook and its template in our config file and add a `he
2424

2525
{% tabs %}
2626
{% tab title="YAML" %}
27-
{% code lineNumbers="true" %}
27+
{% code title="config/packages/sylius_bootstrap_admin_ui.yaml" lineNumbers="true" %}
2828
```yaml
29-
# config/packages/sylius_bootstrap_admin_ui.yaml
3029
# ...
3130
sylius_twig_hooks:
3231
hooks:
@@ -41,9 +40,8 @@ sylius_twig_hooks:
4140
{% endtab %}
4241
4342
{% tab title="PHP" %}
44-
{% code lineNumbers="true" %}
43+
{% code title="config/packages/sylius_bootstrap_admin_ui.php" lineNumbers="true" %}
4544
```php
46-
// config/packages/sylius_bootstrap_admin_ui.php
4745
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
4846

4947
return static function (ContainerConfigurator $containerConfigurator): void {
@@ -77,9 +75,8 @@ Note that you can also use [Symfony Expression Language](https://symfony.com/doc
7775

7876
{% tabs %}
7977
{% tab title="YAML" %}
80-
{% code lineNumbers="true" %}
78+
{% code title="config/packages/sylius_bootstrap_admin_ui.yaml" lineNumbers="true" %}
8179
```yaml
82-
# config/packages/sylius_bootstrap_admin_ui.yaml
8380
# ...
8481
sylius_twig_hooks:
8582
hooks:
@@ -94,9 +91,8 @@ sylius_twig_hooks:
9491
{% endtab %}
9592
9693
{% tab title="PHP" %}
97-
{% code lineNumbers="true" %}
94+
{% code title="config/packages/sylius_bootstrap_admin_ui.php" lineNumbers="true" %}
9895
```php
99-
// config/packages/sylius_bootstrap_admin_ui.php
10096
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
10197

10298
return static function (ContainerConfigurator $containerConfigurator): void {
@@ -145,9 +141,8 @@ Here's an example to define a "users" icon on a speaker list.
145141

146142
{% tabs %}
147143
{% tab title="YAML" %}
148-
{% code lineNumbers="true" %}
144+
{% code title="config/packages/sylius_bootstrap_admin_ui.yaml" lineNumbers="true" %}
149145
```yaml
150-
# config/packages/sylius_bootstrap_admin_ui.yaml
151146
# ...
152147
sylius_twig_hooks:
153148
hooks:
@@ -163,9 +158,8 @@ sylius_twig_hooks:
163158
{% endtab %}
164159
165160
{% tab title="PHP" %}
166-
{% code lineNumbers="true" %}
161+
{% code title="config/packages/sylius_bootstrap_admin_ui.php" lineNumbers="true" %}
167162
```php
168-
// config/packages/sylius_bootstrap_admin_ui.php
169163
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
170164

171165
return static function (ContainerConfigurator $containerConfigurator): void {
@@ -199,9 +193,8 @@ You can also define a default icon for every "index" pages.
199193

200194
{% tabs %}
201195
{% tab title="YAML" %}
202-
{% code lineNumbers="true" %}
196+
{% code title="config/packages/sylius_bootstrap_admin_ui.yaml" lineNumbers="true" %}
203197
```yaml
204-
# config/packages/sylius_bootstrap_admin_ui.yaml
205198
# ...
206199
sylius_twig_hooks:
207200
hooks:
@@ -215,9 +208,8 @@ sylius_twig_hooks:
215208
{% endtab %}
216209
217210
{% tab title="PHP" %}
218-
{% code lineNumbers="true" %}
211+
{% code title="config/packages/sylius_bootstrap_admin_ui.php" lineNumbers="true" %}
219212
```php
220-
// config/packages/sylius_bootstrap_admin_ui.php
221213
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
222214

223215
return static function (ContainerConfigurator $containerConfigurator): void {
@@ -255,9 +247,8 @@ Here's an example to define a subheader on a speaker list.
255247

256248
{% tabs %}
257249
{% tab title="YAML" %}
258-
{% code lineNumbers="true" %}
250+
{% code title="config/packages/sylius_bootstrap_admin_ui.yaml" lineNumbers="true" %}
259251
```yaml
260-
# config/packages/sylius_bootstrap_admin_ui.yaml
261252
# ...
262253
sylius_twig_hooks:
263254
hooks:
@@ -273,9 +264,8 @@ sylius_twig_hooks:
273264
{% endtab %}
274265
275266
{% tab title="PHP" %}
276-
{% code lineNumbers="true" %}
267+
{% code title="config/packages/sylius_bootstrap_admin_ui.php" lineNumbers="true" %}
277268
```php
278-
// config/packages/sylius_bootstrap_admin_ui.php
279269
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
280270

281271
return static function (ContainerConfigurator $containerConfigurator): void {

docs/cookbook/admin_panel/security.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Learn more on how to [create a User](https://symfony.com/doc/current/security.ht
2929

3030
Here is an example of a user provider configuration:
3131

32+
{% code title="config/packages/security.yaml" lineNumbers="true" %}
3233
```yaml
33-
# config/packages/security.yaml
3434
security:
3535
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
3636
password_hashers:
@@ -43,6 +43,7 @@ security:
4343
class: App\Entity\User
4444
property: email
4545
```
46+
{% endcode %}
4647
4748
{% hint style="info" %}
4849
Learn more on how to [create a user provider on the Symfony documentation](https://symfony.com/doc/current/security.html#the-user)
@@ -52,8 +53,8 @@ Learn more on how to [create a user provider on the Symfony documentation](https
5253
5354
Here is an example of how to configure a firewall for your admin routes:
5455
56+
{% code title="config/packages/security.yaml" %}
5557
```yaml
56-
# config/packages/security.yaml
5758
security:
5859
firewalls:
5960
# ...
@@ -71,6 +72,7 @@ security:
7172
path: sylius_admin_ui_logout
7273
target: sylius_admin_ui_login
7374
```
75+
{% endcode %}
7476
7577
{% hint style="info" %}
7678
Learn more on how to [configure the firewall on the Symfony documentation](https://symfony.com/doc/current/security.html#the-firewall)
@@ -80,15 +82,16 @@ Learn more on how to [configure the firewall on the Symfony documentation](https
8082
8183
Only admin users will have access to "/admin" routes.
8284
85+
{% code title="config/packages/security.yaml" %}
8386
```yaml
84-
# config/packages/security.yaml
8587
security:
8688
access_control:
8789
- { path: ^/admin/login, roles: PUBLIC_ACCESS }
8890
- { path: ^/admin/logout, roles: PUBLIC_ACCESS }
8991
- { path: ^/admin, roles: ROLE_ADMIN }
9092
- { path: ^/, roles: PUBLIC_ACCESS }
9193
```
94+
{% endcode %}
9295
9396
{% hint style="info" %}
9497
Learn more on how to [configure Access Control Authorization on the Symfony documentation](https://symfony.com/doc/current/security.html#access-control-authorization)

docs/cookbook/ddd_architecture/basic_operations.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ src
3535

3636
In the Application folder, we already have this `CreateBookCommand`:
3737

38+
{% code title="src/Bookstore/Application/Command/CreateBookCommand.php" lineNumbers="true" %}
3839
```php
39-
// src/Bookstore/Application/Command/CreateBookCommand.php
4040

4141
declare(strict_types=1);
4242

@@ -65,15 +65,16 @@ final readonly class CreateBookCommand implements CommandInterface
6565
}
6666
}
6767
```
68+
{% endcode %}
6869

6970
The idea is to reuse this command to create the book in the storage for your "create" operation.
7071

7172
### Create the CreateBookProcessor
7273

7374
First, we need to add the `CreateBookProcessor` in which we're going to call our `CreateBookCommand`.
7475

76+
{% code title="src/BookStore/Infrastructure/Sylius/State/Processor/CreateBookProcessor.php" lineNumbers="true" %}
7577
```php
76-
// src/BookStore/Infrastructure/Sylius/State/Processor/CreateBookProcessor.php
7778

7879
declare(strict_types=1);
7980

@@ -126,13 +127,14 @@ final readonly class CreateBookProcessor implements ProcessorInterface
126127
}
127128
}
128129
```
130+
{% endcode %}
129131

130132
### Adding the processor on the Book Resource
131133

132134
Then, we add the `Create` operation on our `BookResource`.
133135

136+
{% code title="src/BookStore/Infrastructure/Sylius/Resource/BookResource.php" lineNumbers="true" %}
134137
```php
135-
// src/BookStore/Infrastructure/Sylius/Resource/BookResource.php
136138

137139
// ...
138140
use App\BookStore\Infrastructure\Sylius\State\Processor\CreateBookProcessor;
@@ -156,6 +158,7 @@ final class BookResource implements ResourceInterface
156158
// ...
157159
}
158160
```
161+
{% endcode %}
159162

160163
## Book edition
161164

@@ -167,8 +170,8 @@ final class BookResource implements ResourceInterface
167170

168171
Now, we want to be able to edit an existing book. In the Application folder, we already have this `UpdateBookCommand`:
169172

173+
{% code title="src/Bookstore/Application/Command/UpdateBookCommand.php" lineNumbers="true" %}
170174
```php
171-
// src/Bookstore/Application/Command/UpdateBookCommand.php
172175

173176
declare(strict_types=1);
174177

@@ -199,11 +202,12 @@ final readonly class UpdateBookCommand implements CommandInterface
199202
}
200203
}
201204
```
205+
{% endcode %}
202206

203207
In the same folder, we also have this existing `FindBookQuery`:
204208

209+
{% code title="src/BookStore/Application/Query/FindBookQuery.php" lineNumbers="true" %}
205210
```php
206-
// src/BookStore/Application/Query/FindBookQuery.php
207211

208212
declare(strict_types=1);
209213

@@ -224,15 +228,16 @@ final readonly class FindBookQuery implements QueryInterface
224228
}
225229
}
226230
```
231+
{% endcode %}
227232

228233
The idea is to reuse these query and command to update the book in the storage for your "update" operation.
229234

230235
### Create the BookItemProvider
231236

232237
First, we need to create the `BookItemProvider` in order to fetch the right book.
233238

239+
{% code title="src/BookStore/Infrastructure/Sylius/State/Provider/BookItemProvider.php" lineNumbers="true" %}
234240
```php
235-
// src/BookStore/Infrastructure/Sylius/State/Provider/BookItemProvider.php
236241

237242
declare(strict_types=1);
238243

@@ -272,13 +277,14 @@ final readonly class BookItemProvider implements ProviderInterface
272277
}
273278
}
274279
```
280+
{% endcode %}
275281

276282
### Create the UpdateBookProcessor
277283

278284
We also need to create the `UpdateBookProcessor` where we're going to call our `UpdateBookCommand`.
279285

286+
{% code title="src/BookStore/Infrastructure/Sylius/State/Processor/UpdateBookProcessor.php" lineNumbers="true" %}
280287
```php
281-
// src/BookStore/Infrastructure/Sylius/State/Processor/UpdateBookProcessor.php
282288

283289
declare(strict_types=1);
284290

@@ -327,14 +333,14 @@ final readonly class UpdateBookProcessor implements ProcessorInterface
327333
}
328334
}
329335
```
336+
{% endcode %}
330337

331338
### Adding the provider & processor on the Book Resource
332339

333340
Now, we add the "update" operation on the `BookResource`.
334341

342+
{% code title="src/BookStore/Infrastructure/Sylius/Resource/BookResource.php" lineNumbers="true" %}
335343
```php
336-
// src/BookStore/Infrastructure/Sylius/Resource/BookResource.php
337-
338344
// ...
339345
use App\BookStore\Infrastructure\Sylius\State\Processor\UpdateBookProcessor;
340346
use App\BookStore\Infrastructure\Sylius\State\Provider\BookItemProvider;
@@ -359,6 +365,7 @@ final class BookResource implements ResourceInterface
359365
// ...
360366
}
361367
```
368+
{% endcode %}
362369

363370
## Book removal
364371

@@ -370,8 +377,8 @@ final class BookResource implements ResourceInterface
370377

371378
Now that we can update an existing book, we also want to be able to delete it. In the Application folder, we already have this `DeleteBookCommand`:
372379

380+
{% code title="src/BookStore/Application/Command/DeleteBookCommand.php" lineNumbers="true" %}
373381
```php
374-
// src/BookStore/Application/Command/DeleteBookCommand.php
375382

376383
declare(strict_types=1);
377384

@@ -391,13 +398,14 @@ final readonly class DeleteBookCommand implements CommandInterface
391398
}
392399
}
393400
```
401+
{% endcode %}
394402

395403
### Create the DeleteBookProcessor
396404

397405
We need to create the `DeleteBookProcessor`.
398406

407+
{% code title="src/BookStore/Infrastructure/Sylius/State/Processor/DeleteBookProcessor.php" lineNumbers="true" %}
399408
```php
400-
// src/BookStore/Infrastructure/Sylius/State/Processor/DeleteBookProcessor.php
401409

402410
declare(strict_types=1);
403411

@@ -431,14 +439,14 @@ final readonly class DeleteBookProcessor implements ProcessorInterface
431439
}
432440
}
433441
```
442+
{% endcode %}
434443

435444
### Adding the processor on the Book Resource
436445

437446
And then we create the "delete" operation on the BookResource.
438447

448+
{% code title="src/BookStore/Infrastructure/Sylius/Resource/BookResource.php" lineNumbers="true" %}
439449
```php
440-
// src/BookStore/Infrastructure/Sylius/Resource/BookResource.php
441-
442450
// ...
443451
use App\BookStore\Infrastructure\Sylius\State\Processor\DeleteBookProcessor;
444452
use App\BookStore\Infrastructure\Sylius\State\Provider\BookItemProvider;
@@ -460,3 +468,4 @@ final class BookResource implements ResourceInterface
460468
// ...
461469
}
462470
```
471+
{% endcode %}

0 commit comments

Comments
 (0)