You are here

public function TaxNumberTypeWithVerificationBase::verify in Commerce Core 8.2

Verifies the given tax number.

Parameters

string $tax_number: The tax number.

Return value

\Drupal\commerce_tax\Plugin\Commerce\TaxNumberType\VerificationResult The verification result.

Overrides SupportsVerificationInterface::verify

File

modules/tax/src/Plugin/Commerce/TaxNumberType/TaxNumberTypeWithVerificationBase.php, line 66

Class

TaxNumberTypeWithVerificationBase
Provides the base class for tax number types which support verification.

Namespace

Drupal\commerce_tax\Plugin\Commerce\TaxNumberType

Code

public function verify($tax_number) {

  // The verification result is cached in memory for the duration of the
  // request, to account for verify() being called multiple times during
  // one form submission (validate -> submit).
  $cache_id = 'verification:' . $this->pluginId . ':' . $tax_number;
  $cache = $this->memoryCache
    ->get($cache_id);
  if ($cache) {
    $result = $cache->data;
  }
  else {
    $result = $this
      ->doVerify($tax_number);
    $this->memoryCache
      ->set($cache_id, $result);
  }
  return $result;
}