diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorageInterface.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorageInterface.php index fb61301..78048e4 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorageInterface.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorageInterface.php @@ -88,5 +88,4 @@ public function loadOriginal($id); */ public function loadMultipleOriginal(array $ids = NULL); - } diff --git a/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php b/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php index 4c097f7..6f3d8e6 100644 --- a/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php +++ b/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php @@ -36,10 +36,8 @@ public function testFormsWithOverrides() { ); $this->writeSettings($settings); - // Test that the overridden label is used on a regular page. - $this->drupalGet('config_test/dotted.default'); - $this->assertText($overridden_label); - $this->assertNoText($original_label); + // Test that the overridden label is loaded with the entity. + $this->assertEqual(config_test_load('dotted.default')->label(), $overridden_label); // Test that the original label on the listing page is intact. $this->drupalGet('admin/structure/config_test'); @@ -66,12 +64,8 @@ public function testFormsWithOverrides() { $elements = $this->xpath('//input[@name="label"]'); $this->assertIdentical((string) $elements[0]['value'], $edited_label); - // Test that the overridden label is used on a regular page regardless of - // the change to the label on the edit form. - $this->drupalGet('config_test/dotted.default'); - $this->assertText($overridden_label); - $this->assertNoText($original_label); - $this->assertNoText($edited_label); + // Test that the overridden label is still loaded with the entity. + $this->assertEqual(config_test_load('dotted.default')->label(), $overridden_label); } } diff --git a/core/modules/config/tests/config_test/config_test.routing.yml b/core/modules/config/tests/config_test/config_test.routing.yml index 1695459..3a96481 100644 --- a/core/modules/config/tests/config_test/config_test.routing.yml +++ b/core/modules/config/tests/config_test/config_test.routing.yml @@ -59,13 +59,6 @@ entity.config_test.delete_form_config_test_no_status: requirements: _access: 'TRUE' -config_test.page: - path: '/config_test/{config_test}' - defaults: - _controller: '\Drupal\config_test\ConfigTestController::page' - requirements: - _access: 'TRUE' - config_test.schema_listener: path: '/config_test/schema_listener' defaults: diff --git a/core/modules/config/tests/config_test/src/ConfigTestController.php b/core/modules/config/tests/config_test/src/ConfigTestController.php index 5150f67..cb62642 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestController.php +++ b/core/modules/config/tests/config_test/src/ConfigTestController.php @@ -18,19 +18,6 @@ class ConfigTestController extends ControllerBase { /** - * Route callback. - * - * @param \Drupal\config_test\Entity\ConfigTest $config_test - * The ConfigTest object. - * - * @return string - * The label of the ConfigTest object. - */ - public function page(ConfigTest $config_test) { - return $config_test->label(); - } - - /** * Route title callback. * * @param \Drupal\config_test\Entity\ConfigTest $config_test diff --git a/core/modules/system/tests/modules/keyvalue_test/keyvalue_test.module b/core/modules/system/tests/modules/keyvalue_test/keyvalue_test.module index 97d1269..74549db 100644 --- a/core/modules/system/tests/modules/keyvalue_test/keyvalue_test.module +++ b/core/modules/system/tests/modules/keyvalue_test/keyvalue_test.module @@ -11,7 +11,7 @@ function keyvalue_test_entity_type_alter(array &$entity_types) { /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ if (isset($entity_types['config_test'])) { - $entity_types['config_test']->setStorageClass('Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage'); + $entity_types['config_test']->setStorageClass('Drupal\Core\Entity\KeyValueStore\KeyValueConfigEntityStorage'); } if (isset($entity_types['entity_test_label'])) { $entity_types['entity_test_label']->setStorageClass('Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage'); diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueConfigEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueConfigEntityStorage.php new file mode 100644 index 0000000..6b41189 --- /dev/null +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueConfigEntityStorage.php @@ -0,0 +1,100 @@ +configFactory = $config_factory; + } + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { + return new static( + $entity_type, + $container->get('keyvalue')->get('entity_storage__' . $entity_type->id()), + $container->get('uuid'), + $container->get('language_manager'), + $container->get('config.factory') + ); + } + + /** + * @inheritdoc + */ + public static function getIDFromConfigName($config_name, $config_prefix) { } + + /** + * @inheritdoc + */ + public function createFromStorageRecord(array $values) { } + + /** + * @inheritdoc + */ + public function updateFromStorageRecord(ConfigEntityInterface $entity, array $values) { } + + /** + * {@inheritdoc} + */ + public function loadOriginal($id) { + $old_state = $this->configFactory->getOverrideState(); + $this->configFactory->setOverrideState(FALSE); + $entity = $this->load($id); + $this->configFactory->setOverrideState($old_state); + return $entity; + } + + /** + * {@inheritdoc} + */ + public function loadMultipleOriginal(array $ids = NULL) { + $old_state = $this->configFactory->getOverrideState(); + $this->configFactory->setOverrideState(FALSE); + $entities = $this->loadMultiple($ids); + $this->configFactory->setOverrideState($old_state); + return $entities; + } + +}