diff --git a/core/lib/Drupal/Core/Entity/EntityFieldManager.php b/core/lib/Drupal/Core/Entity/EntityFieldManager.php index c9f56c67aabb..916a4dcac0d3 100644 --- a/core/lib/Drupal/Core/Entity/EntityFieldManager.php +++ b/core/lib/Drupal/Core/Entity/EntityFieldManager.php @@ -590,6 +590,8 @@ class EntityFieldManager implements EntityFieldManagerInterface { // proper provider setter. See https://www.drupal.org/node/2225961. if ($definition instanceof BaseFieldDefinition) { $definition->setProvider($module); + $definition->setName($field_name); + $definition->setTargetEntityTypeId($entity_type_id); } $field_definitions[$field_name] = $definition; } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php index 16f94e0a2a81..c41bbcd47df2 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php @@ -262,7 +262,15 @@ class EntityFieldManagerTest extends UnitTestCase { $field_storage_definition = $this->prophesize(FieldStorageDefinitionInterface::class); $field_storage_definition->getName()->willReturn('field_storage'); - $definitions = ['field_storage' => $field_storage_definition->reveal()]; + $base_field_definition = $this->prophesize(BaseFieldDefinition::class); + $base_field_definition->setProvider('example_module')->shouldBeCalled(); + $base_field_definition->setName('base_field')->shouldBeCalled(); + $base_field_definition->setTargetEntityTypeId('test_entity_type')->shouldBeCalled(); + + $definitions = [ + 'base_field' => $base_field_definition->reveal(), + 'field_storage' => $field_storage_definition->reveal(), + ]; $this->moduleHandler->getImplementations('entity_base_field_info')->willReturn([]); $this->moduleHandler->getImplementations('entity_field_storage_info')->willReturn(['example_module']); @@ -271,6 +279,7 @@ class EntityFieldManagerTest extends UnitTestCase { $expected = [ 'id' => $field_definition, + 'base_field' => $base_field_definition->reveal(), 'field_storage' => $field_storage_definition->reveal(), ]; $this->assertSame($expected, $this->entityFieldManager->getFieldStorageDefinitions('test_entity_type'));