commerce_amws-8.x-1.x-dev/modules/shipping/src/CommerceAmwsShippingServiceProvider.php

modules/shipping/src/CommerceAmwsShippingServiceProvider.php
<?php

namespace Drupal\commerce_amws_shipping;

use Drupal\commerce_amws_shipping\EntitySync\FeedPostOrderFulfillmentDataFactory;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Symfony\Component\DependencyInjection\Reference;

/**
 * Service alterations.
 */
class CommerceAmwsShippingServiceProvider extends ServiceProviderBase {

  /**
   * {@inheritdoc}
   */
  public function register(ContainerBuilder $container) {
    $modules = $container->getParameter('container.modules');
    if (!isset($modules['commerce_amws_feed'])) {
      return;
    }

    $container
      ->register(
        'commerce_amws_shipping.entity_sync_client.feed_post_order_fulfillment_data_factory',
        FeedPostOrderFulfillmentDataFactory::class
      )
      ->addArgument(new Reference('entity_type.manager'))
      ->addArgument(new Reference('commerce_amws_feed.xml_content_builder'));
  }

  /**
   * {@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_shipping.shipment_service');
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc