function RegisterEntityResolversCompilerPass::process
Same name in other branches
- 9 core/modules/serialization/src/RegisterEntityResolversCompilerPass.php \Drupal\serialization\RegisterEntityResolversCompilerPass::process()
- 10 core/modules/serialization/src/RegisterEntityResolversCompilerPass.php \Drupal\serialization\RegisterEntityResolversCompilerPass::process()
- 11.x core/modules/serialization/src/RegisterEntityResolversCompilerPass.php \Drupal\serialization\RegisterEntityResolversCompilerPass::process()
Adds services to the Serializer.
Parameters
\Symfony\Component\DependencyInjection\ContainerBuilder $container: The container to process.
File
-
core/
modules/ serialization/ src/ RegisterEntityResolversCompilerPass.php, line 20
Class
- RegisterEntityResolversCompilerPass
- Adds services tagged 'entity_resolver' to the Serializer.
Namespace
Drupal\serializationCode
public function process(ContainerBuilder $container) {
$definition = $container->getDefinition('serializer.entity_resolver');
$resolvers = [];
// 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', [
$resolver,
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.