Skip to content

Use env vars to trigger hooks #266

@maximehuran

Description

@maximehuran

I tried this syntax while creating a hook :

sylius_twig_hooks:
    hooks:
        'sylius_shop.base.header.top_bar':
            my_hook:
                template: '/shop/my_hook.html.twig'
                priority: 0
                enabled: '%env(bool:ENABLE_MY_HOOK)%'

The hook is always enabled, even if the env var ENABLE_MY_HOOK is false.

I tried also to define a parameter like this

parameters:
    app.enable_my_hook: '%env(bool:ENABLE_MY_HOOK)%'

And used it in the hook declaration :

sylius_twig_hooks:
    hooks:
        'sylius_shop.base.header.top_bar':
            my_hook:
                template: '/shop/my_hook.html.twig'
                priority: 0
                enabled: '%app.enable_my_hook%'

This feature flag worked when we used Sylius UI twig events in Sylius 1.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions