Many services use Drupal\common\EventDispatcherTrait because we needed a backwards-compatibility layer between Drupal 8 and 9. See: https://github.com/GetDKAN/dkan/issues/3592
Currently, no one should be using Drupal 8, and we don't have Drupal 9 in our testing matrix.
Furthermore, services should be injected into other services, avoiding the \Drupal pattern.
So let's deprecate EventDispatcherTrait and remove its usage in DKAN.
Expected Behavior
Add a @deprecated annotation to EventDispatcherTrait.
Inject the event_dispatcher service into classes that currently use the trait.
Modify those classes to use their own dispatcher instead of the one called in the trait.
Current Behavior
Many services use
Drupal\common\EventDispatcherTrait
because we needed a backwards-compatibility layer between Drupal 8 and 9. See: https://github.com/GetDKAN/dkan/issues/3592Currently, no one should be using Drupal 8, and we don't have Drupal 9 in our testing matrix.
Furthermore, services should be injected into other services, avoiding the
\Drupal
pattern.So let's deprecate
EventDispatcherTrait
and remove its usage in DKAN.Expected Behavior
@deprecated
annotation toEventDispatcherTrait
.event_dispatcher
service into classes that currently use the trait.Steps To Reproduce
See that we use EventDispatcherTrait.
Decide that it's not a good pattern.
Fix it.
Relevant log output (optional)
No response
Anything else?
No response