commerce_amws-8.x-1.x-dev/modules/order/src/EntitySync/OrderItemClientFactory.php
modules/order/src/EntitySync/OrderItemClientFactory.php
<?php
namespace Drupal\commerce_amws_order\EntitySync;
use Drupal\commerce_amws_order\Api\OrderItemClient as ApiOrderItemClient;
use Drupal\entity_sync\Client\ProviderClientFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
/**
* Factory for generating order item API clients.
*/
class OrderItemClientFactory implements ProviderClientFactoryInterface {
/**
* The AMWS store storage.
*
* @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface
*/
protected $amwsStoreStorage;
/**
* Constructs a new OrderClientFactory object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->amwsStoreStorage = $entity_type_manager
->getStorage('commerce_amws_store');
}
/**
* {@inheritdoc}
*/
public function get($sync_id, array $parameters) {
return new OrderItemClient(
new ApiOrderItemClient(
$this->amwsStoreStorage->load($parameters['amws_store_id'])
)
);
}
}
