public function BatUnit::formatEventValue in Booking and Availability Management Tools for Drupal 7
Parameters
string $event_type:
$value:
Return value
mixed
File
- modules/
bat_unit/ bat_unit.module, line 1035
Class
- BatUnit
- The class used for unit entities.
Code
public function formatEventValue($event_type, $value) {
$bat_type = bat_type_load($this->type_id);
$field = $bat_type
->getEventValueDefaultField($event_type);
$field_info = field_info_field($field);
$field_info_instance = field_info_instance('bat_type', $field, $bat_type->type);
if ($field_info['type'] == 'commerce_price') {
if (empty($field_info_instance['widget']['settings']['currency_code']) || $field_info_instance['widget']['settings']['currency_code'] == 'default') {
$currency_code = NULL;
}
else {
$currency_code = $field_info_instance['widget']['settings']['currency_code'];
}
$price = array(
'amount' => $value,
'currency_code' => $currency_code,
);
$field_view_value = field_view_value('bat_type', $bat_type, $field, $price);
}
elseif ($field_info['type'] == 'number_integer') {
$field_view_value = field_view_value('bat_type', $bat_type, $field, array(
'value' => $value,
));
}
else {
$field_view_value = field_view_value('bat_type', $bat_type, $field, $value);
}
return $field_view_value['#markup'];
}