You are here

public function TaxNumberItem::getAllowedTypes in Commerce Core 8.2

Gets the allowed tax number types.

Determined based on the allowed countries.

Return value

string[] A list of plugin IDs.

Overrides TaxNumberItemInterface::getAllowedTypes

1 call to TaxNumberItem::getAllowedTypes()
TaxNumberItem::getConstraints in modules/tax/src/Plugin/Field/FieldType/TaxNumberItem.php
Gets a list of validation constraints.

File

modules/tax/src/Plugin/Field/FieldType/TaxNumberItem.php, line 294

Class

TaxNumberItem
Plugin implementation of the 'commerce_tax_number' field type.

Namespace

Drupal\commerce_tax\Plugin\Field\FieldType

Code

public function getAllowedTypes() {
  $tax_number_type_manager = $this
    ->getTaxNumberTypeManager();
  $countries = array_filter($this
    ->getSetting('countries'));
  if ($countries) {
    $types = [];
    foreach ($countries as $country_code) {
      $types[] = $tax_number_type_manager
        ->getPluginId($country_code);
    }
    $types = array_unique($types);
  }
  else {

    // All types are allowed.
    $types = array_keys($tax_number_type_manager
      ->getDefinitions());
  }

  // Ensure a consistent ordering of plugin IDs.
  sort($types);
  return $types;
}