diff --git a/core/modules/entity_reference/entity_reference.views.inc b/core/modules/entity_reference/entity_reference.views.inc index 75b9899..0f85fc6 100644 --- a/core/modules/entity_reference/entity_reference.views.inc +++ b/core/modules/entity_reference/entity_reference.views.inc @@ -40,21 +40,29 @@ function entity_reference_field_views_data(FieldStorageConfigInterface $field_st // the field. $entity_type_id = $field_storage->getTargetEntityTypeId(); $entity_type = $entity_manager->getDefinition($entity_type_id); - $args['@label'] = $entity_type->getLabel(); + $args['@entity'] = $entity_type->getLabel(); + $args['@label'] = $target_entity_type->getLowercaseLabel(); $pseudo_field_name = 'reverse__' . $entity_type_id . '__' . $field_storage->getName(); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping(); $data[$target_base_table][$pseudo_field_name]['relationship'] = array( - 'title' => t('@label using @field_name', $args), - 'help' => t('Relate each @label with a @field_name.', $args), + 'title' => t('@entity using @field_name', $args), + 'help' => t('Relate each @entity with a @field_name set to the @label.', $args), 'id' => 'entity_reverse', 'field_name' => $field_storage->getName(), + 'entity_type' => $entity_type_id, 'field table' => $table_mapping->getDedicatedDataTableName($field_storage), 'field field' => $field_storage->getName() . '_target_id', 'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(), 'base field' => $entity_type->getKey('id'), 'label' => t('@field_name', array('@field_name' => $field_storage->getName())), - 'entity type' => $entity_type_id, + 'join_extra' => array( + 0 => array( + 'field' => 'deleted', + 'value' => 0, + 'numeric' => TRUE, + ), + ), ); } diff --git a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php index 323e8c2..e650f29 100644 --- a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php +++ b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php @@ -187,7 +187,9 @@ public function testRelationshipViewsData() { $this->assertEqual($views_data['reverse__entity_test_mul__field_data_test']['relationship']['base field'], 'id'); $this->assertEqual($views_data['reverse__entity_test_mul__field_data_test']['relationship']['field table'], 'entity_test_mul__field_data_test'); $this->assertEqual($views_data['reverse__entity_test_mul__field_data_test']['relationship']['field field'], 'field_data_test_target_id'); - $this->assertEqual($views_data['reverse__entity_test_mul__field_data_test']['relationship']['entity type'], 'entity_test_mul'); + $this->assertEqual($views_data['reverse__entity_test_mul__field_data_test']['relationship']['field_name'], 'field_data_test'); + $this->assertEqual($views_data['reverse__entity_test_mul__field_data_test']['relationship']['entity_type'], 'entity_test_mul'); + $this->assertEqual($views_data['reverse__entity_test_mul__field_data_test']['relationship']['join_extra'][0], ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE]); // Create reference from entity_test to entity_test_mul. FieldStorageConfig::create(array( @@ -219,7 +221,9 @@ public function testRelationshipViewsData() { $this->assertEqual($views_data['reverse__entity_test__field_test_data']['relationship']['base field'], 'id'); $this->assertEqual($views_data['reverse__entity_test__field_test_data']['relationship']['field table'], 'entity_test__field_test_data'); $this->assertEqual($views_data['reverse__entity_test__field_test_data']['relationship']['field field'], 'field_test_data_target_id'); - $this->assertEqual($views_data['reverse__entity_test__field_test_data']['relationship']['entity type'], 'entity_test'); + $this->assertEqual($views_data['reverse__entity_test__field_test_data']['relationship']['field_name'], 'field_test_data'); + $this->assertEqual($views_data['reverse__entity_test__field_test_data']['relationship']['entity_type'], 'entity_test'); + $this->assertEqual($views_data['reverse__entity_test__field_test_data']['relationship']['join_extra'][0], ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE]); } } diff --git a/core/modules/file/file.views.inc b/core/modules/file/file.views.inc index 870a76a..d8d691a 100644 --- a/core/modules/file/file.views.inc +++ b/core/modules/file/file.views.inc @@ -55,7 +55,7 @@ function file_field_views_data_views_data_alter(array &$data, FieldStorageConfig 'entity_type' => $entity_type_id, 'field table' => $table_mapping->getDedicatedDataTableName($field_storage), 'field field' => $field_name . '_target_id', - 'base' => $entity_type->getBaseTable(), + 'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(), 'base field' => $entity_type->getKey('id'), 'label' => t('!field_name', array('!field_name' => $field_name)), 'join_extra' => array( diff --git a/core/modules/image/image.views.inc b/core/modules/image/image.views.inc index 1131e87..b9fe66a 100644 --- a/core/modules/image/image.views.inc +++ b/core/modules/image/image.views.inc @@ -54,7 +54,7 @@ function image_field_views_data_views_data_alter(array &$data, FieldStorageConfi 'entity_type' => $entity_type_id, 'field table' => $table_mapping->getDedicatedDataTableName($field_storage), 'field field' => $field_name . '_target_id', - 'base' => $entity_type->getBaseTable(), + 'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(), 'base field' => $entity_type->getKey('id'), 'label' => t('!field_name', array('!field_name' => $field_name)), 'join_extra' => array(