commerce_amws-8.x-1.x-dev/modules/order/src/EntitySync/OrderClientFactory.php
modules/order/src/EntitySync/OrderClientFactory.php
<?php
namespace Drupal\commerce_amws_order\EntitySync;
use Drupal\commerce_amws_order\Api\OrderClient as ApiOrderClient;
use Drupal\entity_sync\Client\ProviderClientFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
/**
* Factory for generating order API clients.
*/
class OrderClientFactory 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 OrderClient(
new ApiOrderClient(
$this->amwsStoreStorage->load($parameters['amws_store_id'])
)
);
}
}
