You are here

public function Currency::getValueOptions in Price 2.0.x

Same name and namespace in other branches
  1. 2.x src/Plugin/views/filter/Currency.php \Drupal\price\Plugin\views\filter\Currency::getValueOptions()

Child classes should be used to override this function and set the 'value options', unless 'options callback' is defined as a valid function or static public method to generate these values.

This can use a guard to be used to reduce database hits as much as possible.

Return value

array|null The stored values from $this->valueOptions.

Overrides InOperator::getValueOptions

File

src/Plugin/views/filter/Currency.php, line 56

Class

Currency
Filter by currency.

Namespace

Drupal\price\Plugin\views\filter

Code

public function getValueOptions() {
  if (!isset($this->valueOptions)) {
    $currency_storage = $this->entityTypeManager
      ->getStorage('price_currency');
    $currencies = $currency_storage
      ->loadMultiple();
    $currency_codes = array_keys($currencies);
    $this->valueOptions = array_combine($currency_codes, $currency_codes);
  }
  return $this->valueOptions;
}