RegisterEntityResolversCompilerPass::process

public RegisterEntityResolversCompilerPass::process(ContainerBuilder $container)

Adds services to the Serializer.

Parameters

\Symfony\Component\DependencyInjection\ContainerBuilder $container: The container to process.

Overrides CompilerPassInterface::process

File

core/modules/serialization/src/RegisterEntityResolversCompilerPass.php, line 20

Class

RegisterEntityResolversCompilerPass
Adds services tagged 'normalizer' and 'encoder' to the Serializer.

Namespace

Drupal\serialization

Code

public function process(ContainerBuilder $container) {
  $definition = $container->getDefinition('serializer.entity_resolver');
  $resolvers = array();

  // Retrieve registered Normalizers and Encoders from the container.
  foreach ($container->findTaggedServiceIds('entity_resolver') as $id => $attributes) {
    $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
    $resolvers[$priority][] = new Reference($id);
  }

  // Add the registered concrete EntityResolvers to the ChainEntityResolver.
  foreach ($this->sort($resolvers) as $resolver) {
    $definition->addMethodCall('addResolver', array($resolver));
  }
}
doc_Drupal
2016-10-29 09:37:05
Comments
Leave a Comment

Please login to continue.