AvailabilityManager.php in Commerce Core 8.2
File
src/AvailabilityManager.php
View source
<?php
namespace Drupal\commerce;
class AvailabilityManager implements AvailabilityManagerInterface {
protected $checkers = [];
public function addChecker(AvailabilityCheckerInterface $checker) {
$this->checkers[] = $checker;
}
public function getCheckers() {
return $this->checkers;
}
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;
}
}