Drupal fight of the century: Hooks versus Events

Drupal fight of the century: Hooks versus Events

Drupal 8 uses some of the Symfony2 components. One of those components is the EventDispatcher.

This component provides a system to register events. Afterwards other modules and plugins can execute code when these events are triggered. For example: When a user registers (= EventDispatcher), send a mail with a confirmation (= EventSubscriber).

The outdated event system in Drupal is widely known as "hooks". Because of the very interesting session "The state of hooking into Drupal", I created a module to replace a lot of common hooks with the new event dispatcher component. This allows you to forget (a little bit) about hooks and use the Symfony integrated event dispatcher component.

You can download, test and use "Hook Event Dispatcher", let me know what you think!

At the time of writing the module provides entity, form and preprocess dispatchers. Happy coding!

Tags