You are here

class LocalStockServiceConfig in Commerce Stock 8

The local stock service configuration class.

Hierarchy

Expanded class hierarchy of LocalStockServiceConfig

1 string reference to 'LocalStockServiceConfig'
commerce_stock_local.services.yml in modules/local_storage/commerce_stock_local.services.yml
modules/local_storage/commerce_stock_local.services.yml
1 service uses LocalStockServiceConfig
commerce_stock.local_stock_service_config in modules/local_storage/commerce_stock_local.services.yml
Drupal\commerce_stock_local\LocalStockServiceConfig

File

modules/local_storage/src/LocalStockServiceConfig.php, line 13

Namespace

Drupal\commerce_stock_local
View source
class LocalStockServiceConfig implements StockServiceConfigInterface {

  /**
   * The stock location storage.
   *
   * @var \Drupal\commerce_stock_local\StockLocationStorageInterface
   */
  protected $storage;

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs the local stock service config.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
    $this->storage = $entity_type_manager
      ->getStorage('commerce_stock_location');
  }

  /**
   * {@inheritdoc}
   */
  public function getTransactionLocation(Context $context, PurchasableEntityInterface $entity, $quantity) {
    return $this->storage
      ->getTransactionLocation($context, $entity);
  }

  /**
   * {@inheritdoc}
   */
  public function getAvailabilityLocations(Context $context, PurchasableEntityInterface $entity) {
    return $this->storage
      ->loadInContext($context, $entity);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LocalStockServiceConfig::$entityTypeManager protected property The entity type manager.
LocalStockServiceConfig::$storage protected property The stock location storage.
LocalStockServiceConfig::getAvailabilityLocations public function Get locations holding stock. Overrides StockServiceConfigInterface::getAvailabilityLocations
LocalStockServiceConfig::getTransactionLocation public function Get the location for automatic stock allocation. Overrides StockServiceConfigInterface::getTransactionLocation
LocalStockServiceConfig::__construct public function Constructs the local stock service config.