function civicrm_entity_ds_fields_info in CiviCRM Entity 7.2
Implements hook_ds_fields_info().
Setup custom display suite "field" handling for CiviCRM properties
Parameters
$entity_type:
Return value
array|void
File
- ./
civicrm_entity.module, line 4025
Code
function civicrm_entity_ds_fields_info($entity_type) {
$fields = array();
if (!civicrm_initialize(TRUE)) {
return;
}
$enabled_entities = _civicrm_entity_enabled_entities();
if (empty($enabled_entities[$entity_type])) {
return;
}
$properties = _civicrm_entity_getproperties(substr($entity_type, 8), 'property_info');
$civicrm_entity_info = civicrm_entity_get_supported_entity_info($entity_type);
// Basic wrapper and class settings for all CiviCRM properties, also makes the label visibility work
foreach ($properties as $name => $settings) {
$fields[$entity_type][$name] = array(
'title' => $settings['label'],
'field_type' => 2,
'function' => '_civicrm_entity_render_fields',
'file' => drupal_get_path('module', 'civicrm_entity') . '/civicrm_entity.ds.inc',
'properties' => array(
'settings' => array(
'wrapper' => array(
'type' => 'textfield',
'description' => t('Eg: h1, h2, p'),
),
'class' => array(
'type' => 'textfield',
'description' => t('Put a class on the wrapper. Eg: block-title'),
),
),
'default' => array(
'wrapper' => 'div',
'class' => 'civicrm-field',
),
),
);
// could do some date formatter logic all at one here
/* if(isset($settings['mysql_type') && $settings['mysql_type'] == 'datetime') {
$fields[$entity_type][$name]['date']['date'] = TRUE;
$fields[$entity_type][$name]['date']['granularity'] = $settings['granularity'];
}*/
}
if (isset($civicrm_entity_info['display suite'])) {
if (isset($civicrm_entity_info['display suite']['link fields']) && count($civicrm_entity_info['display suite']['link fields'])) {
_civicrm_entity_link_addformatters($entity_type, $civicrm_entity_info['display suite']['link fields'], $fields);
}
if (isset($civicrm_entity_info['display suite']['option fields']) && count($civicrm_entity_info['display suite']['option fields'])) {
_civicrm_entity_option_addformatters($entity_type, $civicrm_entity_info['display suite']['option fields'], $fields);
}
if (isset($civicrm_entity_info['display suite']['boolean fields']) && count($civicrm_entity_info['display suite']['boolean fields'])) {
_civicrm_entity_yesno_addformatters($entity_type, $civicrm_entity_info['display suite']['boolean fields'], $fields);
}
if (isset($civicrm_entity_info['display suite']['date fields']) && count($civicrm_entity_info['display suite']['date fields'])) {
_civicrm_entity_date_addformatters($entity_type, $civicrm_entity_info['display suite']['date fields'], $fields);
}
if (isset($civicrm_entity_info['display suite']['timestamp fields']) && count($civicrm_entity_info['display suite']['timestamp fields'])) {
_civicrm_entity_timestamp_addformatters($entity_type, $civicrm_entity_info['display suite']['timestamp fields'], $fields);
}
}
if (isset($fields[$entity_type])) {
return array(
$entity_type => $fields[$entity_type],
);
}
}