diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index 155246d..1181953 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -170,10 +170,11 @@ protected function getDefinitionWithReplacements($base_plugin_id, array $replace // Replace dynamic portions of the definition type. if (!empty($replacements) && strpos($definition['type'], ']')) { - $type = $this->determineType($this->replaceName($definition['type'], $replacements), $definitions); + $sub_type = $this->determineType($this->replaceName($definition['type'], $replacements), $definitions); // Merge the newly determined subtype definition with the original // definition. - $definition = NestedArray::mergeDeepArray([$definitions[$type], $definition], TRUE); + $definition = NestedArray::mergeDeepArray([$definitions[$sub_type], $definition], TRUE); + $type = "$type||$sub_type"; } // Unset type so we try the merge only once per type. unset($definition['type']); diff --git a/core/modules/config/src/Tests/ConfigSchemaTest.php b/core/modules/config/src/Tests/ConfigSchemaTest.php index 56fe862..a89db0e 100644 --- a/core/modules/config/src/Tests/ConfigSchemaTest.php +++ b/core/modules/config/src/Tests/ConfigSchemaTest.php @@ -573,6 +573,10 @@ public function testConfigSaveWithWrappingSchemaDoubleBrackets() { $this->assertIdentical(\Drupal::config('wrapping.config_schema_test.double_brackets') ->get(), $typed_values); + $tests = \Drupal::service('config.typed')->get('wrapping.config_schema_test.double_brackets')->get('tests')->getElements(); + $definition = $tests[0]->getDataDefinition()->toArray(); + $this->assertEqual($definition['type'], 'wrapping.test.double_brackets.*||test.double_brackets.turtle.horse'); + $untyped_values = [ 'tests' => [ [ @@ -602,6 +606,36 @@ public function testConfigSaveWithWrappingSchemaDoubleBrackets() { ->save(); $this->assertIdentical(\Drupal::config('wrapping.config_schema_test.double_brackets') ->get(), $typed_values); + + $tests = \Drupal::service('config.typed')->get('wrapping.config_schema_test.double_brackets')->get('tests')->getElements(); + $definition = $tests[0]->getDataDefinition()->toArray(); + $this->assertEqual($definition['type'], 'wrapping.test.double_brackets.*||test.double_brackets.cat.dog'); + + // Combine everything in a single save. + $typed_values = [ + 'tests' => [ + [ + 'wrapper_value' => 'foo', + 'foo' => 'cat', + 'bar' => 'dog', + 'another_key' => 100, + ], + [ + 'wrapper_value' => 'foo', + 'foo' => 'turtle', + 'bar' => 'horse', + 'another_key' => '100', + ], + ], + ]; + \Drupal::configFactory()->getEditable('wrapping.config_schema_test.double_brackets') + ->setData($typed_values) + ->save(); + $tests = \Drupal::service('config.typed')->get('wrapping.config_schema_test.double_brackets')->get('tests')->getElements(); + $definition = $tests[0]->getDataDefinition()->toArray(); + $this->assertEqual($definition['type'], 'wrapping.test.double_brackets.*||test.double_brackets.cat.dog'); + $definition = $tests[1]->getDataDefinition()->toArray(); + $this->assertEqual($definition['type'], 'wrapping.test.double_brackets.*||test.double_brackets.turtle.horse'); } }