You are here

function CurrencyViewsHandlerField::render in Currency 7.2

Overrides parent::render().

Throws

RuntimeException

Overrides views_handler_field::render

File

currency/includes/CurrencyViewsHandlerField.inc, line 22
Contains class CurrencyViewsHandlerField.

Class

CurrencyViewsHandlerField
A Views field handler for fields that contain ISO 4217 currency codes.

Code

function render($values) {
  $property = !empty($this->definition['currency_property']) ? $this->definition['currency_property'] : NULL;
  if ($property && property_exists('Currency', $property)) {
    $currency_code = $this
      ->get_value($values);
    $currency = currency_load($currency_code);
    if ($currency) {
      if ($property == 'title') {
        return $currency
          ->translateTitle();
      }
      else {
        return $currency->{$property};
      }
    }
    else {
      return t('Unknuwn currency %currency_code', array(
        '%currency_code' => $currency_code,
      ));
    }
  }
  throw new RuntimeException(t('CurrencyViewsHandlerField requires a set-up currency property handler definition.'));
}