You are here

protected function StoreTax::getTaxTypes in Commerce Core 8.2

Gets the available tax types.

Return value

\Drupal\commerce_tax\Entity\TaxTypeInterface[] The tax types.

1 call to StoreTax::getTaxTypes()
StoreTax::getDefaultTaxType in modules/tax/src/StoreTax.php
Gets the default tax type for the given store.

File

modules/tax/src/StoreTax.php, line 135

Class

StoreTax

Namespace

Drupal\commerce_tax

Code

protected function getTaxTypes() {
  if (empty($this->taxTypes)) {
    $tax_type_storage = $this->entityTypeManager
      ->getStorage('commerce_tax_type');

    /** @var \Drupal\commerce_tax\Entity\TaxTypeInterface[] $tax_types */
    $this->taxTypes = $tax_type_storage
      ->loadMultiple();
    foreach ($this->taxTypes as $tax_type_id => $tax_type) {
      if (!$tax_type
        ->status()) {
        unset($this->taxTypes[$tax_type_id]);
      }
      $tax_type_plugin = $tax_type
        ->getPlugin();
      if (!$tax_type_plugin instanceof LocalTaxTypeInterface || !$tax_type_plugin
        ->isDisplayInclusive()) {
        unset($this->taxTypes[$tax_type_id]);
      }
    }
    uasort($this->taxTypes, [
      TaxType::class,
      'sort',
    ]);
  }
  return $this->taxTypes;
}