Skip to content

Commit 6678539

Browse files
committed
TMP
1 parent 8e56520 commit 6678539

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/templating/components.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,33 @@ 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+
=== "PHP Attribute2"
24+
25+
``` php
26+
[[= include_file('code_samples/back_office/components/MyComponent.php') =]]
27+
```
28+
2329
=== "PHP Attribute"
2430

2531
``` php
26-
[[= include_file('code_samples/back_office/components/MyComponent.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+
}
2750
```
2851

2952
=== "YAML configuration"

0 commit comments

Comments
 (0)