Join GitHub today
Hook improvements #1714
This PR aims to simplify the use of hooks and fixes some issues.
Now, it's no longer required to implement your own class to handle hooks. If you only want to render a template or add a css or js file you can do it easily. Here is an example :
<hooks> <hook id="hooknavigation.hook.test"> <tag name="hook.event_listener" event="main.navbar-primary" templates="render:myTemplate.html" /> <tag name="hook.event_listener" event="main.stylesheet" type="front" active="1" templates="css:myCss.css;render:theme.css.html" /> </hook> </hooks>
You can notice that the
The tag syntax is similar and it operates the same way, except for the new argument
The syntax :
I've also added a command to cleanup hooks of a module or for all modules. They will be recreated (with default configuration) when the cache of the application will be cleared :
# remove module hooks of the HookNavigation module (without confirmation) php Thelia hook:clean HookNavigation --assume-yes # remove hooks of all modules (with confirmation) php Thelia hook:clean
Feel free to comment this PR. It's not finished and all your remarks are welcome.