class DefaultContentExtraServiceProvider in Default Content Extras 8
Adds customized normalizer to handle taxonomy hierarchy.
Hierarchy
- class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface
- class \Drupal\default_content_extra\DefaultContentExtraServiceProvider
Expanded class hierarchy of DefaultContentExtraServiceProvider
File
- src/
DefaultContentExtraServiceProvider.php, line 13
Namespace
Drupal\default_content_extraView source
class DefaultContentExtraServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
$modules = $container
->getParameter('container.modules');
// @todo Get rid of after https://www.drupal.org/node/2543726
if (isset($modules['taxonomy'])) {
// Add a normalizer service for term entities.
$service_definition = new Definition('Drupal\\default_content_extra\\Normalizer\\TermEntityNormalizer', [
new Reference('hal.link_manager'),
new Reference('entity_type.manager'),
new Reference('module_handler'),
new Reference('entity_type.repository'),
new Reference('entity_field.manager'),
new Reference('config.factory'),
]);
// The priority must be higher than that of
// serializer.normalizer.entity.hal in hal.services.yml.
$service_definition
->addTag('normalizer', [
'priority' => 50,
]);
$container
->setDefinition('default_content_extra.normalizer.taxonomy_term.halt', $service_definition);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultContentExtraServiceProvider:: |
public | function |
Modifies existing service definitions. Overrides ServiceProviderBase:: |
|
ServiceProviderBase:: |
public | function |
Registers services to the container. Overrides ServiceProviderInterface:: |
1 |