Module Development

Utilize Event Arguments and Request Objects for Drupal 8

Check your version

This tutorial covers a topic in Drupal 8 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 8, but we consider it archived.

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.

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