You are here

class LocalStockService in Commerce Stock 8

The Local stock Service class.

Hierarchy

Expanded class hierarchy of LocalStockService

1 file declares its use of LocalStockService
LocalStockServiceTest.php in modules/local_storage/tests/src/Kernel/LocalStockServiceTest.php
1 string reference to 'LocalStockService'
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 LocalStockService
commerce_stock.local_stock_service in modules/local_storage/commerce_stock_local.services.yml
Drupal\commerce_stock_local\LocalStockService

File

modules/local_storage/src/LocalStockService.php, line 14

Namespace

Drupal\commerce_stock_local
View source
class LocalStockService implements StockServiceInterface {

  /**
   * The stock checker.
   *
   * @var \Drupal\commerce_stock\StockCheckInterface
   */
  protected $stockChecker;

  /**
   * The stock updater.
   *
   * @var \Drupal\commerce_stock\StockUpdateInterface
   */
  protected $stockUpdater;

  /**
   * The stock configuration.
   *
   * @var \Drupal\commerce_stock\StockServiceConfigInterface
   */
  protected $stockServiceConfig;

  /**
   * Constructs a new LocalStockService object.
   *
   * @param \Drupal\commerce_stock\StockCheckInterface $stock_checker
   *   The stock checker.
   * @param \Drupal\commerce_stock\StockUpdateInterface $stock_updater
   *   The stock updater.
   * @param \Drupal\commerce_stock\StockServiceConfigInterface $stock_service_config
   *   The stock configuration.
   */
  public function __construct(StockCheckInterface $stock_checker, StockUpdateInterface $stock_updater, StockServiceConfigInterface $stock_service_config) {
    $this->stockChecker = $stock_checker;
    $this->stockUpdater = $stock_updater;
    $this->stockServiceConfig = $stock_service_config;
  }

  /**
   * Creates a new Local stock service.
   *
   * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
   *   The DI container.
   *
   * @return static
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('commerce_stock.local_stock_checker'), $container
      ->get('commerce_stock.local_stock_updater'), $container
      ->get('commerce_stock.local_stock_service_config'));
  }

  /**
   * Get the name of the service.
   */
  public function getName() {
    return 'Local stock';
  }

  /**
   * Get the ID of the service.
   */
  public function getId() {
    return 'local_stock';
  }

  /**
   * Gets the stock checker.
   *
   * @return \Drupal\commerce_stock\StockCheckInterface
   *   The stock checker.
   */
  public function getStockChecker() {
    return $this->stockChecker;
  }

  /**
   * Gets the stock updater.
   *
   * @return \Drupal\commerce_stock\StockUpdateInterface
   *   The stock updater.
   */
  public function getStockUpdater() {
    return $this->stockUpdater;
  }

  /**
   * Gets the stock Configuration.
   *
   * @return \Drupal\commerce_stock\StockServiceConfigInterface
   *   The stock Configuration.
   */
  public function getConfiguration() {
    return $this->stockServiceConfig;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LocalStockService::$stockChecker protected property The stock checker.
LocalStockService::$stockServiceConfig protected property The stock configuration.
LocalStockService::$stockUpdater protected property The stock updater.
LocalStockService::create public static function Creates a new Local stock service.
LocalStockService::getConfiguration public function Gets the stock Configuration. Overrides StockServiceInterface::getConfiguration
LocalStockService::getId public function Get the ID of the service. Overrides StockServiceInterface::getId
LocalStockService::getName public function Get the name of the service. Overrides StockServiceInterface::getName
LocalStockService::getStockChecker public function Gets the stock checker. Overrides StockServiceInterface::getStockChecker
LocalStockService::getStockUpdater public function Gets the stock updater. Overrides StockServiceInterface::getStockUpdater
LocalStockService::__construct public function Constructs a new LocalStockService object.