protected function EntityViewsData::mapFieldDefinition in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/src/EntityViewsData.php \Drupal\views\EntityViewsData::mapFieldDefinition()
- 10 core/modules/views/src/EntityViewsData.php \Drupal\views\EntityViewsData::mapFieldDefinition()
Puts the views data for a single field onto the views data.
Parameters
string $table: The table of the field to handle.
string $field_name: The name of the field to handle.
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition defined in Entity::baseFieldDefinitions()
\Drupal\Core\Entity\Sql\TableMappingInterface $table_mapping: The table mapping information
array $table_data: A reference to a specific entity table (for example data_table) inside the views data.
1 call to EntityViewsData::mapFieldDefinition()
- EntityViewsData::getViewsData in core/
modules/ views/ src/ EntityViewsData.php - Returns views data for the entity type.
File
- core/
modules/ views/ src/ EntityViewsData.php, line 401
Class
- EntityViewsData
- Provides generic views integration for entities.
Namespace
Drupal\viewsCode
protected function mapFieldDefinition($table, $field_name, FieldDefinitionInterface $field_definition, TableMappingInterface $table_mapping, &$table_data) {
// Create a dummy instance to retrieve property definitions.
$field_column_mapping = $table_mapping
->getColumnNames($field_name);
$field_schema = $this
->getFieldStorageDefinitions()[$field_name]
->getSchema();
$field_definition_type = $field_definition
->getType();
// Add all properties to views table data. We need an entry for each
// column of each field, with the first one given special treatment.
// @todo Introduce concept of the "main" column for a field, rather than
// assuming the first one is the main column. See also what the
// mapSingleFieldViewsData() method does with $first.
$first = TRUE;
foreach ($field_column_mapping as $field_column_name => $schema_field_name) {
$table_data[$schema_field_name] = $this
->mapSingleFieldViewsData($table, $field_name, $field_definition_type, $field_column_name, $field_schema['columns'][$field_column_name]['type'], $first, $field_definition);
$table_data[$schema_field_name]['entity field'] = $field_name;
$first = FALSE;
}
}