class EntityReferenceLayoutServiceProvider in Entity Reference with Layout 8
Service Provider for Entity Reference Revisions.
Hierarchy
- class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface
- class \Drupal\entity_reference_layout\EntityReferenceLayoutServiceProvider
Expanded class hierarchy of EntityReferenceLayoutServiceProvider
File
- src/
EntityReferenceLayoutServiceProvider.php, line 13
Namespace
Drupal\entity_reference_layoutView source
class EntityReferenceLayoutServiceProvider 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 entity reference
// revision items.
$service_definition = new Definition('\\Drupal\\entity_reference_layout\\Normalizer\\EntityReferenceLayoutItemNormalizer', [
new Reference('hal.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.entity_layout_revision_item', $service_definition);
}
// Check for installed Replicate module.
if (isset($modules['replicate'])) {
// Add a Replicate field event subscriber.
$service_definition = new Definition('Drupal\\entity_reference_layout\\EventSubscriber\\ReplicateFieldSubscriber', [
new Reference('replicate.replicator'),
]);
$service_definition
->addTag('event_subscriber');
$service_definition
->setPublic(TRUE);
$container
->setDefinition('replicate.event_subscriber.entity_reference_layout', $service_definition);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityReferenceLayoutServiceProvider:: |
public | function |
Modifies existing service definitions. Overrides ServiceProviderBase:: |
|
ServiceProviderBase:: |
public | function |
Registers services to the container. Overrides ServiceProviderInterface:: |
1 |