class ChainPriceResolver in Commerce Core 8.2
Default implementation of the chain base price resolver.
Hierarchy
- class \Drupal\commerce_price\Resolver\ChainPriceResolver implements ChainPriceResolverInterface
Expanded class hierarchy of ChainPriceResolver
1 string reference to 'ChainPriceResolver'
- commerce_price.services.yml in modules/
price/ commerce_price.services.yml - modules/price/commerce_price.services.yml
1 service uses ChainPriceResolver
File
- modules/
price/ src/ Resolver/ ChainPriceResolver.php, line 11
Namespace
Drupal\commerce_price\ResolverView source
class ChainPriceResolver implements ChainPriceResolverInterface {
/**
* The resolvers.
*
* @var \Drupal\commerce_price\Resolver\PriceResolverInterface[]
*/
protected $resolvers = [];
/**
* Constructs a new ChainBasePriceResolver object.
*
* @param \Drupal\commerce_price\Resolver\PriceResolverInterface[] $resolvers
* The resolvers.
*/
public function __construct(array $resolvers = []) {
$this->resolvers = $resolvers;
}
/**
* {@inheritdoc}
*/
public function addResolver(PriceResolverInterface $resolver) {
$this->resolvers[] = $resolver;
}
/**
* {@inheritdoc}
*/
public function getResolvers() {
return $this->resolvers;
}
/**
* {@inheritdoc}
*/
public function resolve(PurchasableEntityInterface $entity, $quantity, Context $context) {
foreach ($this->resolvers as $resolver) {
$result = $resolver
->resolve($entity, $quantity, $context);
if ($result) {
return $result;
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ChainPriceResolver:: |
protected | property | The resolvers. | |
ChainPriceResolver:: |
public | function |
Adds a resolver. Overrides ChainPriceResolverInterface:: |
|
ChainPriceResolver:: |
public | function |
Gets all added resolvers. Overrides ChainPriceResolverInterface:: |
|
ChainPriceResolver:: |
public | function |
Resolves a price for the given purchasable entity. Overrides PriceResolverInterface:: |
|
ChainPriceResolver:: |
public | function | Constructs a new ChainBasePriceResolver object. |