class ChainPriceResolver in Price 2.0.x
Default implementation of the chain base price resolver.
Hierarchy
- class \Drupal\price\Resolver\ChainPriceResolver implements ChainPriceResolverInterface
Expanded class hierarchy of ChainPriceResolver
1 string reference to 'ChainPriceResolver'
1 service uses ChainPriceResolver
File
- src/
Resolver/ ChainPriceResolver.php, line 11
Namespace
Drupal\price\ResolverView source
class ChainPriceResolver implements ChainPriceResolverInterface {
/**
* The resolvers.
*
* @var \Drupal\price\Resolver\PriceResolverInterface[]
*/
protected $resolvers = [];
/**
* Constructs a new ChainBasePriceResolver object.
*
* @param \Drupal\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(ContentEntityInterface $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. |