diff --git a/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/MappingSubscriber.php b/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/MappingSubscriber.php new file mode 100644 index 0000000..f08a89f --- /dev/null +++ b/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/MappingSubscriber.php @@ -0,0 +1,34 @@ +getInputUris(); + $siteSchemaTypes = $event->getSiteSchemaTypes(); + foreach ($inputUris as $inputUri) { + if (isset($siteSchemaTypes[$inputUri])) { + $event->setSiteSchemaUri($inputUri); + $event->stopPropagation(); + } + } + } + + /** + * Implements EventSubscriberInterface::getSubscribedEvents(). + */ + static function getSubscribedEvents() { + $events[RdfMappingEvents::MAP_INPUT_TYPES] = 'mapInputTypes'; + return $events; + } +} diff --git a/core/modules/rdf/lib/Drupal/rdf/RdfBundle.php b/core/modules/rdf/lib/Drupal/rdf/RdfBundle.php index e32fd8d..d08ff88 100644 --- a/core/modules/rdf/lib/Drupal/rdf/RdfBundle.php +++ b/core/modules/rdf/lib/Drupal/rdf/RdfBundle.php @@ -20,8 +20,14 @@ class RdfBundle extends Bundle { * Overrides Symfony\Component\HttpKernel\Bundle\Bundle::build(). */ public function build(ContainerBuilder $container) { + // Mapping subscriber. + $container->register('rdf.mapping', 'Drupal\rdf\EventSubscriber\MappingSubscriber') + ->addTag('event_subscriber'); + // Route subscriber. $container->register('rdf.route_subscriber', 'Drupal\rdf\EventSubscriber\RouteSubscriber') ->addTag('event_subscriber'); + + // Mapping manager service. $container->register('rdf.site_schema.mapping_manager', 'Drupal\rdf\RdfMappingManager') ->addArgument(new Reference('dispatcher')); } diff --git a/core/modules/rdf/lib/Drupal/rdf/RdfMappingManager.php b/core/modules/rdf/lib/Drupal/rdf/RdfMappingManager.php index df34c63..b374b0e 100644 --- a/core/modules/rdf/lib/Drupal/rdf/RdfMappingManager.php +++ b/core/modules/rdf/lib/Drupal/rdf/RdfMappingManager.php @@ -13,7 +13,6 @@ use Drupal\rdf\RdfMappingEvents; use Drupal\rdf\SiteSchema\BundleSchema; use Drupal\rdf\SiteSchema\SiteSchema; -use Drupal\rdf\SiteSchema\SchemaConstants; /** * Manager for mapping internal and external schema terms. @@ -42,8 +41,8 @@ class RdfMappingManager { public function __construct(EventDispatcherInterface $dispatcher) { $this->dispatcher = $dispatcher; $this->siteSchemas = array( - new SiteSchema(SchemaConstants::CONTENT_STAGING), - new SiteSchema(SchemaConstants::SYNDICATION), + new SiteSchema(SiteSchema::CONTENT_DEPLOYMENT), + new SiteSchema(SiteSchema::SYNDICATION), ); } @@ -144,20 +143,6 @@ protected function mapInputTypes($inputRdfTypes) { $siteSchemaTypes = $this->getCacheData('rdf:site_schema:types'); $typeMap = new MapInputTypesEvent($inputRdfTypes, $siteSchemaTypes); - // Add the default listener. This doesn't do any mapping, it only sets the - // event's site schema URI if one of the incoming RDF types is a site - // schema type URI. - $this->dispatcher->addListener(RdfMappingEvents::MAP_INPUT_TYPES, function (MapInputTypesEvent $event) { - $inputUris = $event->getInputUris(); - $siteSchemaTypes = $event->getSiteSchemaTypes(); - foreach ($inputUris as $inputUri) { - if (isset($siteSchemaTypes[$inputUri])) { - $event->setSiteSchemaUri($inputUri); - $event->stopPropagation(); - } - } - }); - // Allow other modules to map the incoming type URIs to an internal site // schema type URI. For example, a content deployment module could take // URIs from the staging site's schema and map them to the corresponding