You are here

function availability_calendar_field_property_info_alter in Availability Calendars 7.5

Callback to alter the property info for fields, in our case the Availability Calendar field.

Parameters

array $info:

string $entity_type:

array $field:

array $instance: param array $field_type

1 string reference to 'availability_calendar_field_property_info_alter'
availability_calendar_field_info in ./availability_calendar.field.inc
Implements hook_field_info(). @link http://api.drupal.org/api/drupal/modules--field--field.api.php/function/...

File

./availability_calendar.entity.inc, line 122
Contains Entity API and Search API hooks and callbacks.

Code

function availability_calendar_field_property_info_alter(&$info, $entity_type, $field, $instance) {
  $name = $field['field_name'];
  $property =& $info[$entity_type]['bundles'][$instance['bundle']]['properties'][$name];
  if ($field['cardinality'] != 1) {
    $property['type'] = "list<{$property['type']}>";
  }
  $property['getter callback'] = 'entity_metadata_field_verbatim_get';
  $property['setter callback'] = 'entity_metadata_field_verbatim_set';
  $property['property info'] = array(
    'cid' => array(
      'type' => 'availability_calendar_calendar',
      'label' => t('Availability Calendar'),
      'description' => t('The reference to the Availability Calendar.'),
      'getter callback' => 'entity_property_verbatim_get',
      'setter callback' => 'entity_property_verbatim_set',
    ),
  );
  if (!empty($instance['settings']['allow_disable'])) {
    $property['property info']['enabled'] = array(
      'type' => 'boolean',
      'label' => t('Enabled'),
      'description' => t('If the calendar is enabled'),
      'getter callback' => 'entity_property_verbatim_get',
      'setter callback' => 'entity_property_verbatim_set',
    );
  }
  if (!empty($instance['settings']['add_name'])) {
    $property['property info']['name'] = array(
      'type' => 'string',
      'label' => t('Name'),
      'description' => t('The name of the calendar'),
      'sanitized' => FALSE,
      'sanitize' => 'check_plain',
      'getter callback' => 'entity_property_verbatim_get',
      'setter callback' => 'entity_property_verbatim_set',
    );
  }
}