You are here

function CurrencyAmountViewsHandlerField::getCurrency in Currency 7.2

Loads the Currency for this field.

Parameters

stdClass $values: A values object as received by $this->render().

Return value

Currency

Throws

RuntimeException

1 call to CurrencyAmountViewsHandlerField::getCurrency()
CurrencyAmountViewsHandlerField::render in currency/includes/CurrencyAmountViewsHandlerField.inc
Overrides parent::render().

File

currency/includes/CurrencyAmountViewsHandlerField.inc, line 113
Contains class CurrencyAmountViewsHandlerField.

Class

CurrencyAmountViewsHandlerField
A Views field handler for currency amounts.

Code

function getCurrency(stdClass $values) {
  $currency = NULL;
  if ($this->definition['currency_code_field']) {
    $currency_code = $this
      ->get_value($values, 'currency_code_field');
    if ($currency_code) {
      $currency = currency_load($currency_code);
    }
  }
  if (!$currency) {
    $currency = currency_load($this->definition['currency_code']);
  }
  if (!$currency) {
    $currency = currency_load('XXX');
  }
  if (!$currency) {
    throw new RuntimeException(t('Could not load currency with ISO 4217 code XXX.'));
  }
  return $currency;
}