class CommerceProductServiceProvider in Commerce Core 8.2
Swap field rendered when layout builder module is on.
Hierarchy
- class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface
- class \Drupal\commerce_product\CommerceProductServiceProvider
Expanded class hierarchy of CommerceProductServiceProvider
File
- modules/
product/ src/ CommerceProductServiceProvider.php, line 12
Namespace
Drupal\commerce_productView source
class CommerceProductServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
// Get list of modules.
$modules = $container
->getParameter('container.modules');
// Check if there is layout builder and swap field renderer service.
if (isset($modules['layout_builder'])) {
$definition = $container
->getDefinition('commerce_product.variation_field_renderer');
$definition
->setClass(ProductVariationFieldRendererLayoutBuilder::class)
->addArgument(new Reference('entity_display.repository'));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CommerceProductServiceProvider:: |
public | function |
Modifies existing service definitions. Overrides ServiceProviderBase:: |
|
ServiceProviderBase:: |
public | function |
Registers services to the container. Overrides ServiceProviderInterface:: |
1 |