Use env vars to trigger hooks
Open
Nobody has claimed this yet.
feature
- Dominant language
- PHP
- Stars
- 45
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
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
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
Reproduce the hook configuration from the issue with ENABLE_MY_HOOK set to false, then inspect the hook configuration handling to see why the enabled value is ignored. Confirm the behavior with both false and true environment values; done means the hook is disabled or enabled accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100