Skip to content
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

Allow the enabled property of a sylius_ui template to be defined using the ExpressionLanguage Component #15851

Open
JeanDavidDaviet opened this issue Feb 16, 2024 · 0 comments
Assignees

Comments

@JeanDavidDaviet
Copy link

Describe the proposed solution
In the Sylius/Bundle/UiBundle/Registry/TemplateBlockRegistry.php there are theses lines :

$enabledFinalizedTemplateBlocks = array_filter(
            $this->findFinalizedForEvents($eventNames),
            static fn (TemplateBlock $templateBlock): bool => $templateBlock->isEnabled(),
        );

Right now it allow to enable or disable a template from a configuration file.
But it only allow to define ahead of time if yes or no it should be enabled.

sylius.admin.create:
    template: "@Bundle/example.html.twig"
    enabled: true # or false

It would be nice to be able to express logic based on external factor, ex: given a certain parameter in the URL.
I think we could use the ExpressionLanguage Component, like it's use in other part of the Sylius configuration files

Describe alternatives you've considered
I tried to implements the TemplateBlockRegistryInterface, but the compilerPass in Sylius/Bundle/UiBundle/DependencyInjection/SyliusUiExtension.php always refer to the TemplateBlockRegistry
I tried to decorate the TemplateBlockRegistry, but it's not public when compiled.

Additional context

sylius.admin.create:
    template: "@Bundle/example.html.twig"
    enabled: "expr:request.get('id') == 1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants