commerce_amws-8.x-1.x-dev/modules/order/src/CommerceAmwsOrderServiceProvider.php
modules/order/src/CommerceAmwsOrderServiceProvider.php
<?php
namespace Drupal\commerce_amws_order;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
/**
* Service alterations.
*/
class CommerceAmwsOrderServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
// On branch `2.x` we introduced the dependency to the Entity
// Synchronization module, which is installed by an update
// function. Updating Commerce Amazon MWS to the `2.x` branch on existing
// sites fails because a number of its services depend on services provided
// by the Entity Synchronization module - which is not enabled yet.
// Here, we remove such services if the Entity Synchronization module is not
// enabled yet. This will allow the script that runs the database updates to
// continue and, once the update function installs the module, the services
// will be added to the container on the next build.
// We should be removing this when we reach a stable release.
$modules = $container->getParameter('container.modules');
if (isset($modules['entity_sync'])) {
return;
}
$container->removeDefinition('commerce_amws_order.hook.cron');
$container->removeDefinition('commerce_amws_order.import.order_set_store');
$container->removeDefinition('commerce_amws_order.import.order_set_items');
$container->removeDefinition(
'commerce_amws_order.import.order_trigger_dependent_syncs'
);
}
}
