X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fviews%2Fsrc%2FEntityViewsData.php;h=f5672d3dcecec32140cbba86c3ff72faf60b2eaf;hb=5b8bb166bfa98770daef9de5c127fc2e6ef02340;hp=2ba2086ac10397f529244f4a0afdd50683f71725;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/views/src/EntityViewsData.php b/web/core/modules/views/src/EntityViewsData.php index 2ba2086ac..f5672d3dc 100644 --- a/web/core/modules/views/src/EntityViewsData.php +++ b/web/core/modules/views/src/EntityViewsData.php @@ -183,6 +183,13 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac 'id' => 'entity_operations', ], ]; + $data[$revision_table]['operations'] = [ + 'field' => [ + 'title' => $this->t('Operations links'), + 'help' => $this->t('Provides links to perform entity operations.'), + 'id' => 'entity_operations', + ], + ]; } if ($this->entityType->hasViewBuilderClass()) { @@ -200,7 +207,7 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac $data[$base_table]['table']['join'][$data_table] = [ 'left_field' => $base_field, 'field' => $base_field, - 'type' => 'INNER' + 'type' => 'INNER', ]; $data[$data_table]['table']['group'] = $this->entityType->getLabel(); $data[$data_table]['table']['provider'] = $this->entityType->getProvider(); @@ -236,9 +243,19 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac 'type' => 'INNER', ]; } + + // Add a filter for showing only the latest revisions of an entity. + $data[$revision_table]['latest_revision'] = [ + 'title' => $this->t('Is Latest Revision'), + 'help' => $this->t('Restrict the view to only revisions that are the latest revision of their entity.'), + 'filter' => ['id' => 'latest_revision'], + ]; } $this->addEntityLinks($data[$base_table]); + if ($views_revision_base_table) { + $this->addEntityLinks($data[$views_revision_base_table]); + } // Load all typed data definitions of all fields. This should cover each of // the entity base, revision, data tables. @@ -300,7 +317,7 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac // Add the entity type key to each table generated. $entity_type_id = $this->entityType->id(); - array_walk($data, function(&$table_data) use ($entity_type_id){ + array_walk($data, function (&$table_data) use ($entity_type_id) { $table_data['table']['entity type'] = $entity_type_id; }); @@ -371,13 +388,10 @@ class EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterfac // @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. - $multiple = (count($field_column_mapping) > 1); $first = TRUE; foreach ($field_column_mapping as $field_column_name => $schema_field_name) { - $views_field_name = ($multiple) ? $field_name . '__' . $field_column_name : $field_name; - $table_data[$views_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[$views_field_name]['entity field'] = $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; } }