Add service alias for Symfony\Component\EventDispatcher\EventDispatcherInterface

Created on 9 July 2025, 7 days ago

Problem/Motivation

The event_dispatcher service currently has two aliases:

  Psr\EventDispatcher\EventDispatcherInterface: '@event_dispatcher'
  Symfony\Contracts\EventDispatcher\EventDispatcherInterface: '@event_dispatcher'

The concrete class Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher implements Symfony\Component\EventDispatcher\EventDispatcherInterface, which is more specific than the two interfaces that are aliasing the service.

This means if you want to autowire the service, phpstan will think you have the interface from Symfony\Contracts, and you can't make use of methods from Symfony\Component, such as ::addListener and ::removeListener.

Steps to reproduce

Proposed resolution

Add a service alias:

  Symfony\Component\EventDispatcher\EventDispatcherInterface: '@event_dispatcher'

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡¦πŸ‡ΊAustralia mstrelan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024