Skip to content

Commit d4fa21c

Browse files
committed
Documented Twig Component attribute
1 parent 3a74680 commit d4fa21c

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace App\Twig\Component;
4+
5+
use Ibexa\Contracts\TwigComponents\Attribute\AsTwigComponent;
6+
use Ibexa\Contracts\TwigComponents\ComponentInterface;
7+
8+
#[AsTwigComponent(
9+
group: 'admin-ui-dashboard-all-tab-groups'
10+
)]
11+
final class MyComponent implements ComponentInterface
12+
{
13+
public function render(array $parameters = []): string
14+
{
15+
return 'Hello world!';
16+
}
17+
}

docs/templating/components.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ You can create Twig Components in one of two ways:
2020

2121
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:
2222

23-
``` yaml
24-
App\Component\MyNewComponent:
25-
tags:
26-
- { name: ibexa.twig.component, group: content-edit-form-before, priority: 0 }
27-
```
23+
=== "PHP Attribute"
24+
25+
``` php
26+
[[= include_file('code_samples/back_office/components/MyComponent.php') =]]
27+
```
28+
29+
=== "YAML configuration"
30+
31+
``` yaml
32+
App\Component\MyNewComponent:
33+
tags:
34+
- { name: ibexa.twig.component, group: content-edit-form-before, priority: 0 }
35+
```
2836

2937
The available attributes are:
3038

0 commit comments

Comments
 (0)