Skip to content

Commit 324dcc6

Browse files
committed
Fixes
1 parent 89ca2a4 commit 324dcc6

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

docs/templating/components.md

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,21 @@ You can create Twig Components in one of two ways:
1818

1919
### PHP code
2020

21-
Create a class implementing the `\Ibexa\Contracts\TwigComponents\ComponentInterface` interface and register it as a service by using the `ibexa.twig.component` service tag, for example:
22-
23-
=== "PHP Attribute2"
24-
25-
``` php
26-
[[= include_file('code_samples/back_office/components/MyComponent.php', 0, None, ' ') =]]
27-
```
21+
Create a class implementing the `\Ibexa\Contracts\TwigComponents\ComponentInterface` interface.
22+
Register it as a service by using the `AsTwigComponent` attribute or the `ibexa.twig.component` service tag:
2823

2924
=== "PHP Attribute"
3025

3126
``` php
32-
<?php declare(strict_types=1);
33-
34-
namespace App\Twig\Component;
35-
36-
use Ibexa\Contracts\TwigComponents\Attribute\AsTwigComponent;
37-
use Ibexa\Contracts\TwigComponents\ComponentInterface;
38-
39-
#[AsTwigComponent(
40-
group: 'admin-ui-dashboard-all-tab-groups',
41-
priority: 100
42-
)]
43-
final class MyComponent implements ComponentInterface
44-
{
45-
public function render(array $parameters = []): string
46-
{
47-
return 'Hello world!';
48-
}
49-
}
27+
[[= include_file('code_samples/back_office/components/MyComponent.php', glue=' ') =]]
5028
```
5129

5230
=== "YAML configuration"
5331

5432
``` yaml
55-
App\Component\MyNewComponent:
33+
App\Twig\Component\MyComponent:
5634
tags:
57-
- { name: ibexa.twig.component, group: content-edit-form-before, priority: 0 }
35+
- { name: ibexa.twig.component, group: admin-ui-dashboard-all-tab-groups, priority: 0 }
5836
```
5937

6038
The available attributes are:

0 commit comments

Comments
 (0)