You are here

class ChainTaxCodeResolver in Drupal Commerce Connector for AvaTax 8

Provides the chain tax code resolver.

Hierarchy

Expanded class hierarchy of ChainTaxCodeResolver

1 string reference to 'ChainTaxCodeResolver'
commerce_avatax.services.yml in ./commerce_avatax.services.yml
commerce_avatax.services.yml
1 service uses ChainTaxCodeResolver
commerce_avatax.chain_tax_code_resolver in ./commerce_avatax.services.yml
Drupal\commerce_avatax\Resolver\ChainTaxCodeResolver

File

src/Resolver/ChainTaxCodeResolver.php, line 10

Namespace

Drupal\commerce_avatax\Resolver
View source
class ChainTaxCodeResolver implements ChainTaxCodeResolverInterface {

  /**
   * The tax code resolvers.
   *
   * @var \Drupal\commerce_avatax\Resolver\TaxCodeResolverInterface[]
   */
  protected $resolvers;

  /**
   * Constructs a new ChainTaxCodeResolver object.
   *
   * @param \Drupal\commerce_avatax\Resolver\TaxCodeResolverInterface[] $resolvers
   *   The tax code resolvers.
   */
  public function __construct(array $resolvers = []) {
    $this->resolvers = $resolvers;
  }

  /**
   * {@inheritdoc}
   */
  public function addResolver(TaxCodeResolverInterface $resolver) {
    $this->resolvers[] = $resolver;
  }

  /**
   * {@inheritdoc}
   */
  public function getResolvers() {
    return $this->resolvers;
  }

  /**
   * {@inheritdoc}
   */
  public function resolve(OrderItemInterface $order_item) {
    foreach ($this->resolvers as $resolver) {
      $result = $resolver
        ->resolve($order_item);
      if ($result) {
        return $result;
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ChainTaxCodeResolver::$resolvers protected property The tax code resolvers.
ChainTaxCodeResolver::addResolver public function Adds a resolver. Overrides ChainTaxCodeResolverInterface::addResolver
ChainTaxCodeResolver::getResolvers public function Gets all added resolvers. Overrides ChainTaxCodeResolverInterface::getResolvers
ChainTaxCodeResolver::resolve public function Resolves the tax code of a given order item.. Overrides TaxCodeResolverInterface::resolve
ChainTaxCodeResolver::__construct public function Constructs a new ChainTaxCodeResolver object.