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:
<?php
namespace Drupal\rdf;
final class RdfMappingEvents {
const MAP_TYPES_FROM_INPUT = 'rdf.map_types_from_input';
}
?>
<?php
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