You are here

class StockAvailabilityChecker in Commerce Stock 8

The entry point for availability checking through Commerce Stock.

Proxies requests to stock services configured for each entity.

@package Drupal\commerce_stock

Hierarchy

Expanded class hierarchy of StockAvailabilityChecker

1 string reference to 'StockAvailabilityChecker'
commerce_stock.services.yml in ./commerce_stock.services.yml
commerce_stock.services.yml
1 service uses StockAvailabilityChecker
commerce_stock.availability_checker in ./commerce_stock.services.yml
Drupal\commerce_stock\StockAvailabilityChecker

File

src/StockAvailabilityChecker.php, line 17

Namespace

Drupal\commerce_stock
View source
class StockAvailabilityChecker implements AvailabilityCheckerInterface {

  /**
   * The stock service manager.
   *
   * @var \Drupal\commerce_stock\StockServiceManagerInterface
   */
  protected $stockServiceManager;

  /**
   * Constructs a new StockAvailabilityChecker object.
   *
   * @param \Drupal\commerce_stock\StockServiceManagerInterface $stock_service_manager
   *   The stock service manager.
   */
  public function __construct(StockServiceManagerInterface $stock_service_manager) {
    $this->stockServiceManager = $stock_service_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function applies(OrderItemInterface $order_item) {
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function check(OrderItemInterface $order_item, Context $context) {
    return (new AvailabilityResult(TRUE))
      ->isNeutral();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StockAvailabilityChecker::$stockServiceManager protected property The stock service manager.
StockAvailabilityChecker::applies public function Determines whether the checker applies to the given order item. Overrides AvailabilityCheckerInterface::applies
StockAvailabilityChecker::check public function Checks the availability of the given order item. Overrides AvailabilityCheckerInterface::check
StockAvailabilityChecker::__construct public function Constructs a new StockAvailabilityChecker object.