You are here

interface AvailabilityCheckerInterface in Commerce Core 8.2

Same name in this branch
  1. 8.2 src/AvailabilityCheckerInterface.php \Drupal\commerce\AvailabilityCheckerInterface
  2. 8.2 modules/order/src/AvailabilityCheckerInterface.php \Drupal\commerce_order\AvailabilityCheckerInterface

Defines the interface for availability checkers.

Hierarchy

Expanded class hierarchy of AvailabilityCheckerInterface

All classes that implement AvailabilityCheckerInterface

2 files declare their use of AvailabilityCheckerInterface
AvailabilityManagerTest.php in modules/order/tests/src/Unit/AvailabilityManagerTest.php
TestAvailabilityChecker.php in modules/order/tests/modules/commerce_order_test/src/TestAvailabilityChecker.php

File

modules/order/src/AvailabilityCheckerInterface.php, line 11

Namespace

Drupal\commerce_order
View source
interface AvailabilityCheckerInterface {

  /**
   * Determines whether the checker applies to the given order item.
   *
   * @param \Drupal\commerce_order\Entity\OrderItemInterface $order_item
   *   The order item.
   *
   * @return bool
   *   TRUE if the checker applies to the given order item, FALSE otherwise.
   */
  public function applies(OrderItemInterface $order_item);

  /**
   * Checks the availability of the given order item.
   *
   * @param \Drupal\commerce_order\Entity\OrderItemInterface $order_item
   *   The order item.
   * @param \Drupal\commerce\Context $context
   *   The context.
   *
   * @return \Drupal\commerce_order\AvailabilityResult
   *   The availability result. AvailabilityResult::unavailable() should be
   *   used to indicate that the given order item is "unavailable" for purchase.
   *   Note that an optional "reason" can be specified.
   */
  public function check(OrderItemInterface $order_item, Context $context);

}

Members

Namesort descending Modifiers Type Description Overrides
AvailabilityCheckerInterface::applies public function Determines whether the checker applies to the given order item. 1
AvailabilityCheckerInterface::check public function Checks the availability of the given order item. 1