Module Development

Utilize Event Arguments and Request Objects for Drupal 8

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Sprout Video

In this tutorial you'll learn how to make use of the event object that are passed to you and the methods that come with it. You'll also learn how to use dependency injection to add a logger for our class and add this argument to our services YAML file.

Note: Drupal 9 now requires Symfony 4.4. The class mentioned at 0:15, \Symfony\Component\HttpKernel\Event\GetResponseEvent, is deprecated. Use \Symfony\Component\HttpKernel\Event\RequestEvent instead.

Additional resources

Introduction to Interfaces — Drupalize.Me
An Introduction to YAML — Drupalize.Me