You are here

class CommerceProductServiceProvider in Commerce Core 8.2

Swap field rendered when layout builder module is on.

Hierarchy

Expanded class hierarchy of CommerceProductServiceProvider

File

modules/product/src/CommerceProductServiceProvider.php, line 12

Namespace

Drupal\commerce_product
View 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

Namesort descending Modifiers Type Description Overrides
CommerceProductServiceProvider::alter public function Modifies existing service definitions. Overrides ServiceProviderBase::alter
ServiceProviderBase::register public function Registers services to the container. Overrides ServiceProviderInterface::register 1