diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index 6d0a3f4..9fb3db6 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -137,6 +137,16 @@ public function loadByProperties(array $values = array()) { } /** + * Returns the config prefix used by the configuration entity type. + * + * @return string + * The full configuration prefix, for example 'views.view.'. + */ + public function getConfigPrefix() { + return $this->entityInfo['config_prefix'] . '.'; + } + + /** * Builds the query to load the entity. * * This has full revision support. For entities requiring special queries, @@ -159,7 +169,7 @@ public function loadByProperties(array $values = array()) { */ protected function buildQuery($ids, $revision_id = FALSE) { $config_class = $this->entityInfo['class']; - $prefix = $this->entityInfo['config_prefix'] . '.'; + $prefix = $this->getConfigPrefix(); // Load all of the configuration entities. if ($ids === NULL) { @@ -251,7 +261,7 @@ public function delete(array $entities) { } foreach ($entities as $id => $entity) { - $config = config($this->entityInfo['config_prefix'] . '.' . $entity->id()); + $config = config($this->getConfigPrefix() . $entity->id()); $config->delete(); // Remove the entity from the manifest file. @@ -273,7 +283,7 @@ public function delete(array $entities) { * When attempting to save a configuration entity that has no ID. */ public function save(EntityInterface $entity) { - $prefix = $this->entityInfo['config_prefix'] . '.'; + $prefix = $this->getConfigPrefix(); // Configuration entity IDs are strings, and '0' is a valid ID. $id = $entity->id(); @@ -323,9 +333,9 @@ public function save(EntityInterface $entity) { // Add this entity to the manifest file if necessary. $config = config('manifest.' . $this->entityInfo['config_prefix']); $manifest = $config->get(); - if (!in_array($this->entityInfo['config_prefix'] . '.' . $entity->id(), $manifest)) { + if (!in_array($this->getConfigPrefix() . $entity->id(), $manifest)) { $manifest[$entity->id()] = array( - 'name' => $this->entityInfo['config_prefix'] . '.' . $entity->id(), + 'name' => $this->getConfigPrefix() . $entity->id(), ); $config->setData($manifest)->save(); } diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php new file mode 100644 index 0000000..d64c73a --- /dev/null +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php @@ -0,0 +1,43 @@ + 'Configuration entity methods', + 'description' => 'Unit tests for configuration entity base methods.', + 'group' => 'Configuration', + ); + } + + /** + * Tests storage controller methods. + */ + public function testStorageControllerMethods() { + $controller = entity_get_controller('config_test'); + $info = entity_get_info('config_test'); + + $expected = $info['config_prefix'] . '.'; + $this->assertIdentical($controller->getConfigPrefix(), $expected); + } + +}