No event id dispatched to listen to.

Created on 14 December 2023, 7 months ago
Updated 15 December 2023, 7 months ago

Problem/Motivation

The .api.php file says to not use the hooks anymore and instead listen for the dispatched event ExportEvent or ImportEvent. The problem is there is no event ID to listen for. This means you have to listen on the full class name which isn't obvious at first.

Proposed resolution

Add event IDs for better DX.

πŸ’¬ Support request
Status

Closed: works as designed

Version

1.4

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kevinquillen

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

Comments & Activities

  • Issue created by @kevinquillen
  • Status changed to Closed: works as designed 7 months ago
  • πŸ‡ΊπŸ‡¦Ukraine abramm Lutsk

    Hi kevinquillen,

    That's intentional. Since Drupal 9.1, the event name is not required. Instead, the event class name is used if it's not set.
    See \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch.
    You can simply subscribe to ExportEvent::class, there's no need to maintain separate IDs constants for that.

    I'm closing this issue as it works as designed, please reopen if you disagree. Thanks!

Production build 0.69.0 2024