public function EuropeanUnionVat::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/ src/ Plugin/ Commerce/ TaxNumberType/ EuropeanUnionVat.php, line 93
Class
- EuropeanUnionVat
- Provides the European Union VAT tax number type.
Namespace
Drupal\commerce_tax\Plugin\Commerce\TaxNumberTypeCode
public function renderVerificationResult(VerificationResult $result) {
$errors = [
// Plugin errors.
'no_extension' => $this
->t('The SOAP PHP extension is missing from the server.'),
'invalid_number' => $this
->t('The tax number is not in the right format.'),
// VIES errors, as defined in the WSDL.
'INVALID_INPUT' => $this
->t('The tax number is not in the right format.'),
'GLOBAL_MAX_CONCURRENT_REQ' => $this
->t('The remote service is temporarily busy. Error code: GLOBAL_MAX_CONCURRENT_REQ.'),
'MS_MAX_CONCURRENT_REQ' => $this
->t('The remote service is temporarily busy. Error code: MS_MAX_CONCURRENT_REQ.'),
'SERVICE_UNAVAILABLE' => $this
->t('The remote service is temporarily unavailable. Error code: SERVICE_UNAVAILABLE.'),
'MS_UNAVAILABLE' => $this
->t('The remote service is temporarily unavailable. Error code: MS_UNAVAILABLE.'),
'TIMEOUT' => $this
->t('The remote service did not reply within the allocated time period.'),
];
$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'],
];
}
if (isset($data['address'])) {
$element['address'] = [
'#type' => 'item',
'#title' => $this
->t('Address'),
'#plain_text' => $data['address'],
];
}
return $element;
}