You are here

public function ChainPriceResolver::resolve in Price 2.0.x

Resolves a price for the given purchasable entity.

Use $context->getData('field_name', 'price') to get the name of the field for which the price is being resolved (e.g "price").

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

string $quantity: The quantity.

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

Return value

\Drupal\price\Price|null A price value object, if resolved. Otherwise NULL, indicating that the next resolver in the chain should be called.

Overrides PriceResolverInterface::resolve

File

src/Resolver/ChainPriceResolver.php, line 47

Class

ChainPriceResolver
Default implementation of the chain base price resolver.

Namespace

Drupal\price\Resolver

Code

public function resolve(ContentEntityInterface $entity, $quantity, Context $context) {
  foreach ($this->resolvers as $resolver) {
    $result = $resolver
      ->resolve($entity, $quantity, $context);
    if ($result) {
      return $result;
    }
  }
}