hook_field_views_data_alter(array &$data, \Drupal\field\FieldStorageConfigInterface $field_storage)
Alter the Views data for a single Field API field.
This is called on all modules even if there is no hook_field_views_data() implementation for the field, and therefore may be used to alter the default data that views_field_default_views_data() supplies for the field storage.
Parameters
array $data: The views data for the field storage. This has the same format as the return value of hook_views_data(). @param \Drupal\field\FieldStorageConfigInterface $field_storage The field storage config entity.
See also
hook_field_views_data_views_data_alter()
Related topics
- Hooks
- Define functions that alter the behavior of Drupal core.
File
- core/modules/views/views.api.php, line 557
- Describes hooks and plugins provided by the Views module.
Code
function hook_field_views_data_alter(array &$data, \Drupal\field\FieldStorageConfigInterface $field_storage) { $entity_type_id = $field_storage->getTargetEntityTypeId(); $field_name = $field_storage->getName(); $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; $table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping(); list($label) = views_entity_field_label($entity_type_id, $field_name); $data['file_managed'][$pseudo_field_name]['relationship'] = array( 'title' => t('@entity using @field', array('@entity' => $entity_type->getLabel(), '@field' => $label)), 'help' => t('Relate each @entity with a @field set to the image.', array('@entity' => $entity_type->getLabel(), '@field' => $label)), 'id' => 'entity_reverse', 'field_name' => $field_name, 'entity_type' => $entity_type_id, 'field table' => $table_mapping->getDedicatedDataTableName($field_storage), 'field field' => $field_name . '_target_id', 'base' => $entity_type->getBaseTable(), 'base field' => $entity_type->getKey('id'), 'label' => $field_name, 'join_extra' => array( 0 => array( 'field' => 'deleted', 'value' => 0, 'numeric' => TRUE, ), ), ); }
Please login to continue.