[TwigHooks][RFC] improving the DX
Open
Nobody has claimed this yet.
feature
- Dominant language
- PHP
- Stars
- 45
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
Before
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
return static function (ContainerConfigurator $container): void {
$container->extension('sylius_twig_hooks', [
'hooks' => [
'sylius_admin.book.show.content' => [
'body' => [
'template' => 'library/book/show/content/body.html.twig',
'priority' => 100,
],
'dropdown' => [
'component' => DropdownComponent::class,
'priority' => 0,
'props' => [],
],
],
],
]);
};
After
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
return static function (TwigHooksConfig $config): void {
$config->withHook(
(new Hook('sylius_admin.book.show.content'))
->withHookable(
(new HookableTemplate('body', 'library/book/show/content/body.html.twig'))
->withPriority(100)
)
->withHookable(
(new HookableComponent('dropdown', DropdownComponent::class))
->withProps([])
->withPriority(0)
)
);
};
Going further on resource operation
Then we could go further and configure them on a specific resource operation.
#[AsResource(
//...
operations: [
new Show(provider: BookItemProvider::class, hooks: [
(new Hook('sylius_admin.book.show.content'))
->withHookable(
(new HookableTemplate('body', 'library/book/show/content/body.html.twig'))
->withPriority(100)
)
->withHookable(
(new HookableComponent('dropdown', DropdownComponent::class))
->withProps([])
->withPriority(0)
)
]),
],
)]
class ShowBookResource implements ResourceInterface
Note: In userland, we do not need to configure a lot of Twig hooks for our custom operations.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start by locating the current TwigHooks extension configuration and the resource-operation handling, then compare both against the proposed fluent API and attribute examples. Done should mean the project has agreed on a concrete API scope and implementation path, including how userland hook configuration is represented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- backend, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100