Skip to content
Snippets Groups Projects
Commit ef50f952 authored by catch's avatar catch
Browse files

Issue #2306455 by hussainweb, alexpott, er.pushpinderrana: Fixed...

Issue #2306455 by hussainweb, alexpott, er.pushpinderrana: Fixed ConfigEntityStorage adds too many dots.
parent 2909a5d0
No related merge requests found
......@@ -132,9 +132,15 @@ public function deleteRevision($revision_id) {
}
/**
* {@inheritdoc}
* Returns the prefix used to create the configuration name.
*
* The prefix consists of the config prefix from the entity type plus a dot
* for separating from the ID.
*
* @return string
* The full configuration prefix, for example 'views.view.'.
*/
public function getConfigPrefix() {
protected function getPrefix() {
return $this->entityType->getConfigPrefix() . '.';
}
......@@ -149,7 +155,7 @@ public static function getIDFromConfigName($config_name, $config_prefix) {
* {@inheritdoc}
*/
protected function doLoadMultiple(array $ids = NULL) {
$prefix = $this->getConfigPrefix();
$prefix = $this->getPrefix();
// Get the names of the configuration entities we are going to load.
if ($ids === NULL) {
......@@ -187,7 +193,7 @@ protected function doCreate(array $values) {
*/
protected function doDelete($entities) {
foreach ($entities as $entity) {
$config = $this->configFactory->get($this->getConfigPrefix() . $entity->id());
$config = $this->configFactory->get($this->getPrefix() . $entity->id());
$config->delete();
}
}
......@@ -224,7 +230,7 @@ public function save(EntityInterface $entity) {
*/
protected function doSave($id, EntityInterface $entity) {
$is_new = $entity->isNew();
$prefix = $this->getConfigPrefix();
$prefix = $this->getPrefix();
if ($id !== $entity->id()) {
// Renaming a config object needs to cater for:
// - Storage needs to access the original object.
......@@ -263,7 +269,7 @@ protected function mapToStorageRecord(EntityInterface $entity) {
* {@inheritdoc}
*/
protected function has($id, EntityInterface $entity) {
$prefix = $this->getConfigPrefix();
$prefix = $this->getPrefix();
$config = $this->configFactory->get($prefix . $id);
return !$config->isNew();
}
......
......@@ -15,14 +15,6 @@
*/
interface ConfigEntityStorageInterface extends EntityStorageInterface {
/**
* Returns the config prefix used by the configuration entity type.
*
* @return string
* The full configuration prefix, for example 'views.view.'.
*/
public function getConfigPrefix();
/**
* Extracts the configuration entity ID from the full configuration name.
*
......
......@@ -45,9 +45,6 @@ protected function setUp() {
public function testStorageMethods() {
$entity_type = \Drupal::entityManager()->getDefinition('config_test');
$expected = $entity_type->getConfigPrefix() . '.';
$this->assertIdentical($this->storage->getConfigPrefix(), $expected);
// Test the static extractID() method.
$expected_id = 'test_id';
$config_name = $entity_type->getConfigPrefix() . '.' . $expected_id;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment