class DynamicEntityReferenceServiceProvider in Dynamic Entity Reference 8
Same name and namespace in other branches
- 8.2 src/DynamicEntityReferenceServiceProvider.php \Drupal\dynamic_entity_reference\DynamicEntityReferenceServiceProvider
Service Provider for Dynamic Entity Reference.
Hierarchy
- class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface
- class \Drupal\dynamic_entity_reference\DynamicEntityReferenceServiceProvider
Expanded class hierarchy of DynamicEntityReferenceServiceProvider
File
- src/
DynamicEntityReferenceServiceProvider.php, line 13
Namespace
Drupal\dynamic_entity_referenceView source
class DynamicEntityReferenceServiceProvider 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 dynamic entity
// reference items.
// To avoid problems the arguments to
// \Drupal\hal\Normalizer\EntityReferenceItemNormalizer change, re-use
// the same constructor arguments and set the additional dependency
// with a setter method.
$parent_definition = $container
->getDefinition('serializer.normalizer.entity_reference_item.hal');
$service_definition = new Definition(DynamicEntityReferenceItemNormalizer::class, $parent_definition
->getArguments());
// The priority must be higher than that of
// serializer.normalizer.entity_reference_item.hal in
// hal.services.yml.
$service_definition
->addTag('normalizer', [
'priority' => $parent_definition
->getTags()['normalizer'][0]['priority'] + 1,
]);
$container
->setDefinition('serializer.normalizer.entity.dynamic_entity_reference_item.hal', $service_definition);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DynamicEntityReferenceServiceProvider:: |
public | function |
Modifies existing service definitions. Overrides ServiceProviderBase:: |
|
ServiceProviderBase:: |
public | function |
Registers services to the container. Overrides ServiceProviderInterface:: |
1 |