class MappingSubscriber

Default RDF mapping handling.

Hierarchy

Expanded class hierarchy of MappingSubscriber

1 file declares its use of MappingSubscriber
RdfMappingEventTest.php in drupal/core/modules/rdf/lib/Drupal/rdf/Tests/RdfMappingEventTest.php
Contains RdfMappingEventTest.
1 string reference to 'MappingSubscriber'
rdf.services.yml in drupal/core/modules/rdf/rdf.services.yml
drupal/core/modules/rdf/rdf.services.yml
1 service uses MappingSubscriber

File

drupal/core/modules/rdf/lib/Drupal/rdf/EventSubscriber/MappingSubscriber.php, line 15
Contains MappingSubscriber.

Namespace

Drupal\rdf\EventSubscriber
View source
class MappingSubscriber implements EventSubscriberInterface {

  /**
   * Stops event if incoming URI is a site schema URI.
   *
   * If the incoming URI is one of the site's own registered types, then
   * mapping is unnecessary. Mapping is only necessary if the incoming type URI
   * is from an external vocabulary.
   *
   * @param \Drupal\rdf\MapTypesFromInputEvent $event
   *   The mapping event.
   */
  public function mapTypesFromInput(\Drupal\rdf\MapTypesFromInputEvent $event) {
    $input_uris = $event
      ->getInputUris();
    $site_schema_types = $event
      ->getSiteSchemaTypes();
    foreach ($input_uris as $input_uri) {
      if (isset($site_schema_types[$input_uri])) {
        $event
          ->setSiteSchemaUri($input_uri);
        $event
          ->stopPropagation();
      }
    }
  }

  /**
   * Implements EventSubscriberInterface::getSubscribedEvents().
   */
  static function getSubscribedEvents() {
    $events[RdfMappingEvents::MAP_TYPES_FROM_INPUT] = 'mapTypesFromInput';
    return $events;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MappingSubscriber::getSubscribedEvents static function Implements EventSubscriberInterface::getSubscribedEvents(). Overrides EventSubscriberInterface::getSubscribedEvents
MappingSubscriber::mapTypesFromInput public function Stops event if incoming URI is a site schema URI.