You are here

class MetatagServiceProvider in Metatag 8

Service Provider for Metatag.

Hierarchy

Expanded class hierarchy of MetatagServiceProvider

File

src/MetatagServiceProvider.php, line 14

Namespace

Drupal\metatag
View source
class MetatagServiceProvider extends ServiceProviderBase {

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

      // Serialization module is enabled, add our metatag normalizers.
      // Priority of the metatag normalizer must be higher than other
      // general-purpose typed data and field item normalizers.
      $metatag = new Definition(MetatagNormalizer::class);
      $metatag
        ->addTag('normalizer', [
        'priority' => 30,
      ]);
      $container
        ->setDefinition('metatag.normalizer.metatag', $metatag);
      $metatag_hal = new Definition(MetatagHalNormalizer::class);
      $metatag_hal
        ->addTag('normalizer', [
        'priority' => 31,
      ]);
      $container
        ->setDefinition('metatag.normalizer.metatag.hal', $metatag_hal);
    }
  }

}

Members

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