You are here

public function CommercePriceServiceProvider::alter in Commerce Core 8.2

Modifies existing service definitions.

Parameters

ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered.

Overrides ServiceProviderBase::alter

File

modules/price/src/CommercePriceServiceProvider.php, line 17

Class

CommercePriceServiceProvider
Swaps the default physical.number_formatter service class.

Namespace

Drupal\commerce_price

Code

public function alter(ContainerBuilder $container) {
  if ($container
    ->hasDefinition('physical.number_formatter')) {
    $container
      ->getDefinition('physical.number_formatter')
      ->setClass(PhysicalNumberFormatter::class)
      ->setArguments([
      new Reference('commerce_price.number_format_repository'),
      new Reference('commerce.current_locale'),
    ]);
  }
}