ChainTaxCodeResolver.php in Drupal Commerce Connector for AvaTax 8
File
src/Resolver/ChainTaxCodeResolver.php
View source
<?php
namespace Drupal\commerce_avatax\Resolver;
use Drupal\commerce_order\Entity\OrderItemInterface;
class ChainTaxCodeResolver implements ChainTaxCodeResolverInterface {
protected $resolvers;
public function __construct(array $resolvers = []) {
$this->resolvers = $resolvers;
}
public function addResolver(TaxCodeResolverInterface $resolver) {
$this->resolvers[] = $resolver;
}
public function getResolvers() {
return $this->resolvers;
}
public function resolve(OrderItemInterface $order_item) {
foreach ($this->resolvers as $resolver) {
$result = $resolver
->resolve($order_item);
if ($result) {
return $result;
}
}
}
}