class AvailabilityManager in Commerce Core 8.2
Same name in this branch
- 8.2 src/AvailabilityManager.php \Drupal\commerce\AvailabilityManager
- 8.2 modules/order/src/AvailabilityManager.php \Drupal\commerce_order\AvailabilityManager
Default implementation of the availability manager.
Hierarchy
- class \Drupal\commerce\AvailabilityManager implements AvailabilityManagerInterface
Expanded class hierarchy of AvailabilityManager
Deprecated
in commerce:8.x-2.18 and is removed from commerce:3.x. Use \Drupal\commerce_order\AvailabilityManager instead.
1 file declares its use of AvailabilityManager
- AvailabilityManagerTest.php in tests/
src/ Unit/ AvailabilityManagerTest.php
1 string reference to 'AvailabilityManager'
1 service uses AvailabilityManager
File
- src/
AvailabilityManager.php, line 11
Namespace
Drupal\commerceView source
class AvailabilityManager implements AvailabilityManagerInterface {
/**
* The checkers.
*
* @var \Drupal\commerce\AvailabilityCheckerInterface[]
*/
protected $checkers = [];
/**
* {@inheritdoc}
*/
public function addChecker(AvailabilityCheckerInterface $checker) {
$this->checkers[] = $checker;
}
/**
* {@inheritdoc}
*/
public function getCheckers() {
return $this->checkers;
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AvailabilityManager:: |
protected | property | The checkers. | |
AvailabilityManager:: |
public | function |
Adds a checker. Overrides AvailabilityManagerInterface:: |
|
AvailabilityManager:: |
public | function |
Checks the availability of the given purchasable entity. Overrides AvailabilityManagerInterface:: |
|
AvailabilityManager:: |
public | function |
Gets all added checkers. Overrides AvailabilityManagerInterface:: |