- π«π·France andypost
Looks it makes no sense after π Enable service autoconfiguration for core event subscribers Fixed
Updated: Comment #N
To register event subscribers currently, you have to add a service with the "event_subscriber" tag.
Considering that we don't use tagged services for discovery consistently in core, this is exposing an unnecessary implementation detail.
I think we can improve DX by adding a dedicated events.yml with a simple schema for registering events and subscribers.
Something like this:
namespace Drupal\rdf;
final class RdfMappingEvents {
const MAP_TYPES_FROM_INPUT = 'rdf.map_types_from_input';
}
namespace Drupal\rdf\EventSubscriber;
use Drupal\rdf\RdfMappingEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class MappingSubscriber implements EventSubscriberInterface {
static function getSubscribedEvents() {
$events[RdfMappingEvents::MAP_TYPES_FROM_INPUT] = 'mapTypesFromInput';
return $events;
}
}
services:
rdf.mapping:
class: Drupal\rdf\EventSubscriber\MappingSubscriber
tags:
- { name: event_subscriber }
Could be something like this:
events:
- rdf.map_types_from_input
subscribers:
rdf.map_types_from_input: Drupal\rdf\EventSubscriber\MappingSubscriber::mapTypesFromInput
Or generically speaking:
subscribers:
config.importer.import:
- callback: config_snapshot_subscriber:onConfigImporterImport
priority: 40
config.importer.validate:
- callback: Drupal\Core\EventSubscriber\ConfigImportSubscriber::onConfigImporterValidate
priority: 40
config.save:
- callback: config.factory:onConfigSave
priority: 255
For dependency injection we can use the ContainerInjectionInterface
Closed: outdated
11.0 π₯
Last updated
Enhances developer experience.
Enhances an existing API or introduces a new subsystem. Depending on the size and impact, possibly backportable to earlier major versions.
Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Looks it makes no sense after π Enable service autoconfiguration for core event subscribers Fixed