public function CommerceCartApiServiceProvider::alter in Commerce Cart API 8
The ::register method runs before the site's service_yamls have been registered. That means the parameter will always be false. We register the decorated service here so that it respects the customized parameter.
Overrides ServiceProviderBase::alter
File
- src/
CommerceCartApiServiceProvider.php, line 26
Class
- CommerceCartApiServiceProvider
- Adds services to the container for Commerce Cart API.
Namespace
Drupal\commerce_cart_apiCode
public function alter(ContainerBuilder $container) {
$parameter = $container
->getParameter('commerce_cart_api');
if ($parameter['use_cart_token_session']) {
$container
->register('commerce_cart_api.cart_token_session', CartTokenSession::class)
->setDecoratedService('commerce_cart.cart_session')
->setPublic(FALSE)
->setArguments([
new Reference('commerce_cart_api.cart_token_session.inner'),
new Reference('request_stack'),
new Reference('tempstore.shared'),
]);
$container
->register('commerce_cart_api.cart_token_session_configuration', CartTokenSessionConfiguration::class)
->setDecoratedService('session_configuration')
->setPublic(FALSE)
->setArguments([
new Reference('commerce_cart_api.cart_token_session_configuration.inner'),
]);
$container
->register('commerce_cart_api.token_cart_convert_subscriber', CartTokenSubscriber::class)
->setArguments([
new Reference('commerce_cart.cart_session'),
new Reference('tempstore.shared'),
])
->addTag('event_subscriber');
}
}