You are here

public function SerbianVat::renderVerificationResult in Commerce Core 8.2

Renders the given verification result.

Parameters

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

Return value

array The render array.

Overrides SupportsVerificationInterface::renderVerificationResult

File

modules/tax/tests/modules/commerce_tax_test/src/Plugin/Commerce/TaxNumberType/SerbianVat.php, line 55

Class

SerbianVat
Provides the Serbian VAT tax number type.

Namespace

Drupal\commerce_tax_test\Plugin\Commerce\TaxNumberType

Code

public function renderVerificationResult(VerificationResult $result) {
  $errors = [
    'http_429' => $this
      ->t('Too many requests.'),
  ];
  $data = $result
    ->getData();
  $element = [];
  if (isset($data['error'])) {
    $error = $data['error'];
    $element['error'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Error'),
      '#plain_text' => isset($errors[$error]) ? $errors[$error] : $error,
    ];
  }
  if (isset($data['name'])) {
    $element['name'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Name'),
      '#plain_text' => $data['name'],
    ];
  }
  return $element;
}