You are here

public function AvailabilityManager::check in Commerce Core 8.2

Same name in this branch
  1. 8.2 src/AvailabilityManager.php \Drupal\commerce\AvailabilityManager::check()
  2. 8.2 modules/order/src/AvailabilityManager.php \Drupal\commerce_order\AvailabilityManager::check()

Checks the availability of the given purchasable entity.

Parameters

\Drupal\commerce\PurchasableEntityInterface $entity: The purchasable entity.

string $quantity: The quantity.

\Drupal\commerce\Context $context: The context.

Return value

bool TRUE if the purchasable entity is available, FALSE otherwise.

Overrides AvailabilityManagerInterface::check

File

src/AvailabilityManager.php, line 37

Class

AvailabilityManager
Default implementation of the availability manager.

Namespace

Drupal\commerce

Code

public function check(PurchasableEntityInterface $entity, $quantity, Context $context) {
  @trigger_error('The ' . get_class($this) . ' is deprecated in commerce:8.x-2.18 and is removed from commerce:3.x. Use \\Drupal\\commerce_order\\AvailabilityManager instead.', E_USER_DEPRECATED);
  foreach ($this->checkers as $checker) {
    if ($checker
      ->applies($entity)) {
      $result = $checker
        ->check($entity, $quantity, $context);
      if ($result === FALSE) {
        return FALSE;
      }
    }
  }
  return TRUE;
}