Skip to content
Snippets Groups Projects
Commit a64d8864 authored by Urvashi Vora's avatar Urvashi Vora Committed by Sascha Grossenbacher
Browse files

Issue #3190436 by paul121, urvashi_vora, Holo96: EntityViewsData Column...

Issue #3190436 by paul121, urvashi_vora, Holo96: EntityViewsData Column information not available for computed entity reference fields
parent 3226dce7
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,7 @@ class EntityViewsData extends CoreEntityViewsData { ...@@ -54,7 +54,7 @@ class EntityViewsData extends CoreEntityViewsData {
// Add missing reverse relationships. Workaround for core issue #2706431. // Add missing reverse relationships. Workaround for core issue #2706431.
$base_fields = $this->getEntityFieldManager()->getBaseFieldDefinitions($entity_type_id); $base_fields = $this->getEntityFieldManager()->getBaseFieldDefinitions($entity_type_id);
$entity_reference_fields = array_filter($base_fields, function (BaseFieldDefinition $field) { $entity_reference_fields = array_filter($base_fields, function (BaseFieldDefinition $field) {
return $field->getType() == 'entity_reference'; return !$field->hasCustomStorage() && $field->getType() == 'entity_reference';
}); });
$this->addReverseRelationships($data, $entity_reference_fields); $this->addReverseRelationships($data, $entity_reference_fields);
// Add views integration for bundle plugin fields. // Add views integration for bundle plugin fields.
......
...@@ -106,6 +106,14 @@ class EnhancedEntity extends RevisionableContentEntityBase implements EntityPubl ...@@ -106,6 +106,14 @@ class EnhancedEntity extends RevisionableContentEntityBase implements EntityPubl
'weight' => -5, 'weight' => -5,
]); ]);
// Add a computed entity reference field for testing.
$fields['computed_entity_ref'] = BaseFieldDefinition::create('entity_reference')
->setLabel('Test entity reference')
->setSetting('target_type', 'entity_test_enhanced')
->setCardinality(1)
->setComputed(TRUE)
->setClass('Drupal\entity_module_test\Field\ComputedEntityRefItemList');
return $fields; return $fields;
} }
......
<?php
namespace Drupal\entity_module_test\Field;
use Drupal\Core\Field\FieldItemList;
use Drupal\Core\TypedData\ComputedItemListTrait;
/**
* Item list for the computed_entity_ref computed entity reference field.
*/
class ComputedEntityRefItemList extends FieldItemList {
use ComputedItemListTrait;
/**
* {@inheritdoc}
*/
protected function computeValue() {
// Always make the field value empty.
$this->list = [];
}
}
...@@ -34,7 +34,7 @@ class EntityDuplicateTest extends BrowserTestBase { ...@@ -34,7 +34,7 @@ class EntityDuplicateTest extends BrowserTestBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected static $modules = ['entity_module_test', 'user', 'entity', 'block']; protected static $modules = ['entity_module_test', 'user', 'entity', 'block', 'views'];
/** /**
* {@inheritdoc} * {@inheritdoc}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment