function availability_calendar_get_field_setting in Availability Calendars 7.5
Returns the value for an availability calendar field setting.
A value is only returned if all availability calendar fields have the same value for the requested setting. If not, null is returned.
Parameters
string $setting:
Return value
mixed
2 calls to availability_calendar_get_field_setting()
- AvailabilityCalendarViewsController::views_data in views/
availability_calendar_views_controller.inc - Overrides the result for hook_views_data().
- availability_calendar_calendar_entity_property_filtered_availability_get in ./
availability_calendar.entity.inc - Entity property getter callback for the 'filtered availability' property.
File
- ./
availability_calendar.entity.inc, line 219 - Contains Entity API and Search API hooks and callbacks.
Code
function availability_calendar_get_field_setting($setting) {
$settings =& drupal_static(__FUNCTION__, array());
if (!array_key_exists($setting, $settings)) {
$settings[$setting] = NULL;
$instances = field_info_field_map();
foreach ($instances as $field_name => $field_map) {
if ($field_map['type'] === 'availability_calendar') {
$field = field_info_field($field_name);
if ($settings[$setting] === NULL) {
// first field of this type: get value for the requested setting
$settings[$setting] = $field['settings'][$setting];
}
else {
if ($settings[$setting] !== $field['settings'][$setting]) {
// Multiple calendar fields with different values for the requested
// setting: we cannot return THE value for this setting; return null.
$settings[$setting] = NULL;
break;
}
}
// else: multiple calendar fields, but so far all these fields have the
// same value for this setting. Continue.
}
}
}
return $settings[$setting];
}