-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
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 ResourceInterfaceNote: In userland, we do not need to configure a lot of Twig hooks for our custom operations.