You are here

class EntityReferenceRevisionsServiceProvider in Entity Reference Revisions 8

Service Provider for Entity Reference Revisions.

Hierarchy

Expanded class hierarchy of EntityReferenceRevisionsServiceProvider

File

src/EntityReferenceRevisionsServiceProvider.php, line 13

Namespace

Drupal\entity_reference_revisions
View source
class EntityReferenceRevisionsServiceProvider extends ServiceProviderBase {

  /**
   * {@inheritdoc}
   */
  public function alter(ContainerBuilder $container) {
    $modules = $container
      ->getParameter('container.modules');
    if (isset($modules['hal'])) {

      // Hal module is enabled, add our new normalizer for entity reference
      // revision items.
      $service_definition = new Definition('Drupal\\entity_reference_revisions\\Normalizer\\EntityReferenceRevisionItemNormalizer', array(
        new Reference('hal.link_manager'),
        new Reference('serializer.entity_resolver'),
      ));

      // The priority must be higher than that of
      // serializer.normalizer.entity_reference_item.hal in
      // hal.services.yml.
      $service_definition
        ->addTag('normalizer', array(
        'priority' => 20,
      ));
      $container
        ->setDefinition('serializer.normalizer.entity_reference_revision_item', $service_definition);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityReferenceRevisionsServiceProvider::alter public function Modifies existing service definitions. Overrides ServiceProviderBase::alter
ServiceProviderBase::register public function Registers services to the container. Overrides ServiceProviderInterface::register 1