Skip to content

Documented Twig Component attribute #2793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: 5.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions code_samples/back_office/components/MyComponent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);

namespace App\Twig\Component;

use Ibexa\Contracts\TwigComponents\Attribute\AsTwigComponent;
use Ibexa\Contracts\TwigComponents\ComponentInterface;

#[AsTwigComponent(
group: 'admin-ui-dashboard-all-tab-groups',
priority: 100
)]
final class MyComponent implements ComponentInterface
{
public function render(array $parameters = []): string
{
return 'Hello world!';
}
}
21 changes: 15 additions & 6 deletions docs/templating/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@

### PHP code

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:
Create a class implementing the `\Ibexa\Contracts\TwigComponents\ComponentInterface` interface.

Check warning on line 21 in docs/templating/components.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/templating/components.md#L21

[Ibexa.EOLWhitespace] Remove whitespace characters from the end of the line.
Raw output
{"message": "[Ibexa.EOLWhitespace] Remove whitespace characters from the end of the line.", "location": {"path": "docs/templating/components.md", "range": {"start": {"line": 21, "column": 96}}}, "severity": "WARNING"}
Register it as a service by using the `AsTwigComponent` attribute or the `ibexa.twig.component` service tag:

``` yaml
App\Component\MyNewComponent:
tags:
- { name: ibexa.twig.component, group: content-edit-form-before, priority: 0 }
```
=== "PHP Attribute"

``` php hl_lines="8-11"
[[= include_file('code_samples/back_office/components/MyComponent.php', glue=' ') =]]
```

=== "YAML configuration"

``` yaml
App\Twig\Component\MyComponent:
tags:
- { name: ibexa.twig.component, group: admin-ui-dashboard-all-tab-groups, priority: 100 }
```

The available attributes are:

Expand Down
Loading