diff --git a/core/modules/entity_reference/entity_reference.views.inc b/core/modules/entity_reference/entity_reference.views.inc index 6915452..47f0179 100644 --- a/core/modules/entity_reference/entity_reference.views.inc +++ b/core/modules/entity_reference/entity_reference.views.inc @@ -16,12 +16,12 @@ function entity_reference_field_views_data(FieldConfigInterface $field) { $entity_manager = \Drupal::entityManager(); foreach ($data as $table_name => $table_data) { // Add a relationship to the target entity type. - $target_type = $field->getSetting('target_type'); - $target_entity_type = $entity_manager->getDefinition($target_type); + $target_entity_type_id = $field->getSetting('target_type'); + $target_entity_type = $entity_manager->getDefinition($target_entity_type_id); $target_base_table = $target_entity_type->getBaseTable(); - // Provide a relationship from field entity type to the referenced entity - // type. + // Provide a relationship for the entity type with the entity reference + // field. $args = array( '@label' => $target_entity_type->getLabel(), '@field_name' => $field->getName(), @@ -29,25 +29,19 @@ function entity_reference_field_views_data(FieldConfigInterface $field) { $data[$table_name][$field->getName()]['relationship'] = array( 'id' => 'standard', 'base' => $target_base_table, - 'entity type' => $target_type, + 'entity type' => $target_entity_type_id, 'base field' => $target_entity_type->getKey('id'), 'relationship field' => $field->getName() . '_target_id', 'title' => t('@label referenced from @field_name', $args), 'label' => t('@field_name: @label', $args), ); - // Provide a relationship from the referenced entity type to the field - // entity type. - $pseudo_field_name = 'reverse_' . $field->getTargetEntityTypeId() . '__' . $field->getName(); + // Provide a reverse relationship for the entity type that is referenced by + // the field. + $pseudo_field_name = 'reverse__' . $field->getTargetEntityTypeId() . '__' . $field->getName(); $data[$target_base_table][$pseudo_field_name]['relationship'] = array( - 'title' => t('@label using @field_name', array( - '@label' => $target_entity_type->getLabel(), - '@field_name' => $field->getName(), - )), - 'help' => t('Relate each @label with a @field_name.', array( - '@label' => $target_entity_type->getLabel(), - '@field_name' => $field->getName(), - )), + 'title' => t('@label using @field_name', $args), + 'help' => t('Relate each @label with a @field_name.', $args), 'id' => 'entity_reverse', 'field_name' => $field->getName(), 'field table' => ContentEntityDatabaseStorage::_fieldTableName($field), diff --git a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php index 73335a5..b8b5eb1 100644 --- a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php +++ b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php @@ -47,8 +47,8 @@ class EntityReferenceRelationshipTest extends ViewUnitTestBase { */ public static function getInfo() { return array( - 'name' => 'Entity Reference: Relationship handler', - 'description' => 'Tests entity reference relationship handler.', + 'name' => 'Entity Reference: Relationship data', + 'description' => 'Tests entity reference relationship data.', 'group' => 'Views module integration', ); }