diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php index 187aeaa..e0c1881 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php @@ -166,7 +166,7 @@ protected function checkStorageClass($class) { /** * {@inheritdoc} */ - public function getPropertiesToExport($entity_id) { + public function getPropertiesToExport() { if (empty($this->mergedConfigExport)) { if (!empty($this->config_export)) { // Always add default properties to be exported. @@ -187,7 +187,7 @@ public function getPropertiesToExport($entity_id) { } } else { - $config_name = $this->getConfigPrefix() . '.' . $entity_id; + $config_name = $this->getConfigPrefix() . '.*'; $definition = $this->getTypedConfig()->getDefinition($config_name); if (!isset($definition['mapping'])) { throw new SchemaIncompleteException(SafeMarkup::format('Incomplete or missing schema for @config_name', ['@config_name' => $config_name])); diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityTypeInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityTypeInterface.php index ebc8282..586465a 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityTypeInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityTypeInterface.php @@ -64,12 +64,9 @@ public function getConfigPrefix(); /** * Gets the config entity properties to export if declared on the annotation. * - * @param string $entity_id - * The entity ID of the configuration entity being exported. - * * @return array * The properties to export or an empty array if they can not be determined. */ - public function getPropertiesToExport($entity_id); + public function getPropertiesToExport(); } diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php index 4ecc8b9..5bf1c70 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityTypeTest.php @@ -138,13 +138,12 @@ public function providerTestGetConfigPrefix() { * @dataProvider providerGetPropertiesToExport */ public function testGetPropertiesToExport($definition, $expected) { - $entity_id = $this->randomMachineName(); $entity_type = $this->setUpConfigEntityType($definition); - $properties_to_export = $entity_type->getPropertiesToExport($entity_id); + $properties_to_export = $entity_type->getPropertiesToExport(); $this->assertSame($expected, $properties_to_export); // Ensure the method is idempotent. - $properties_to_export = $entity_type->getPropertiesToExport($entity_id); + $properties_to_export = $entity_type->getPropertiesToExport(); $this->assertSame($expected, $properties_to_export); } @@ -188,26 +187,31 @@ public function providerGetPropertiesToExport() { * @covers ::getPropertiesToExport */ public function testGetPropertiesToExportFromSchema() { + $definition = [ + 'id' => 'my_config_entity_type', + 'provider' => 'my_module', + ]; + $typed_config_manager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface'); $typed_config_manager->expects($this->once()) ->method('getDefinition') + ->with($definition['provider'] . '.' . $definition['id'] . '.*') ->willReturn(['mapping' => ['id' => '', 'dependencies' => '']]); $container = new ContainerBuilder(); $container->set('config.typed', $typed_config_manager); \Drupal::setContainer($container); - $definition = ['provider' => 'my_module']; $expected = [ 'id' => 'id', 'dependencies' => 'dependencies', ]; $entity_type = $this->setUpConfigEntityType($definition); - $entity_id = $this->randomMachineName(); - $properties_to_export = $entity_type->getPropertiesToExport($entity_id); + + $properties_to_export = $entity_type->getPropertiesToExport(); $this->assertSame($expected, $properties_to_export); // Ensure the method is idempotent. - $properties_to_export = $entity_type->getPropertiesToExport($entity_id); + $properties_to_export = $entity_type->getPropertiesToExport(); $this->assertSame($expected, $properties_to_export); } @@ -215,7 +219,7 @@ public function testGetPropertiesToExportFromSchema() { * @covers ::getPropertiesToExport * * @expectedException \Drupal\Core\Config\Schema\SchemaIncompleteException - * @expectedExceptionMessage Incomplete or missing schema for my_module.example_config_entity_type.the_entity_id + * @expectedExceptionMessage Incomplete or missing schema for my_module.example_config_entity_type.* */ public function testGetPropertiesToExportFromMissingSchema() { $typed_config_manager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface'); @@ -229,12 +233,11 @@ public function testGetPropertiesToExportFromMissingSchema() { $definition = ['provider' => 'my_module']; $expected = []; $entity_type = $this->setUpConfigEntityType($definition); - $entity_id = 'the_entity_id'; - $properties_to_export = $entity_type->getPropertiesToExport($entity_id); + $properties_to_export = $entity_type->getPropertiesToExport(); $this->assertSame($expected, $properties_to_export); // Ensure the method is idempotent. - $properties_to_export = $entity_type->getPropertiesToExport($entity_id); + $properties_to_export = $entity_type->getPropertiesToExport(); $this->assertSame($expected, $properties_to_export); }