You are here

class YamlformServiceProvider in YAML Form 8

Service Provider for Yamlform.

Hierarchy

Expanded class hierarchy of YamlformServiceProvider

File

src/YamlformServiceProvider.php, line 13

Namespace

Drupal\yamlform
View source
class YamlformServiceProvider 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 yamlform items.
      $service_definition = new Definition('Drupal\\yamlform\\Normalizer\\YamlFormEntityReferenceItemNormalizer', [
        new Reference('rest.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', [
        'priority' => 20,
      ]);
      $container
        ->setDefinition('serializer.normalizer.yamlform_entity_reference_item', $service_definition);
    }
  }

}

Members

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