function civicrm_entity_views_data_alter in CiviCRM Entity 8.3
Same name and namespace in other branches
- 7.2 civicrm_entity.module \civicrm_entity_views_data_alter()
Implements hook_views_data_alter().
@note @note Copy and paste of views_views_data_alter to support our storage check.
See also
File
- ./
civicrm_entity.views.inc, line 19
Code
function civicrm_entity_views_data_alter(&$data) {
$entity_type_manager = \Drupal::entityTypeManager();
if (!$entity_type_manager
->hasDefinition('field_storage_config')) {
return;
}
// @codingStandardsIgnoreStart
// Start: views_views_data() snippet.
// Field modules can implement hook_field_views_data() to override the default
// behavior for adding fields.
$module_handler = \Drupal::moduleHandler();
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
foreach ($entity_type_manager
->getStorage('field_storage_config')
->loadMultiple() as $field_storage) {
if (_civicrm_entity_field_get_entity_type_storage($field_storage)) {
$result = (array) $module_handler
->invoke($field_storage
->getTypeProvider(), 'field_views_data', [
$field_storage,
]);
if (empty($result)) {
$result = civicrm_entity_field_default_views_data($field_storage);
}
$module_handler
->alter('field_views_data', $result, $field_storage);
if (is_array($result)) {
$data = NestedArray::mergeDeep($result, $data);
}
}
}
// End: views_views_data() snippet.
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreStart
// Start: views_views_data_alter() snippet.
/** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
foreach ($entity_type_manager
->getStorage('field_storage_config')
->loadMultiple() as $field_storage) {
if (_civicrm_entity_field_get_entity_type_storage($field_storage)) {
$function = $field_storage
->getTypeProvider() . '_field_views_data_views_data_alter';
if (function_exists($function)) {
$function($data, $field_storage);
}
}
}
// End: views_views_data_alter() snippet.
// @codingStandardsIgnoreEnd
}