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 branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -132,9 +132,15 @@ public function deleteRevision($revision_id) { ...@@ -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() . '.'; return $this->entityType->getConfigPrefix() . '.';
} }
...@@ -149,7 +155,7 @@ public static function getIDFromConfigName($config_name, $config_prefix) { ...@@ -149,7 +155,7 @@ public static function getIDFromConfigName($config_name, $config_prefix) {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function doLoadMultiple(array $ids = NULL) { protected function doLoadMultiple(array $ids = NULL) {
$prefix = $this->getConfigPrefix(); $prefix = $this->getPrefix();
// Get the names of the configuration entities we are going to load. // Get the names of the configuration entities we are going to load.
if ($ids === NULL) { if ($ids === NULL) {
...@@ -187,7 +193,7 @@ protected function doCreate(array $values) { ...@@ -187,7 +193,7 @@ protected function doCreate(array $values) {
*/ */
protected function doDelete($entities) { protected function doDelete($entities) {
foreach ($entities as $entity) { foreach ($entities as $entity) {
$config = $this->configFactory->get($this->getConfigPrefix() . $entity->id()); $config = $this->configFactory->get($this->getPrefix() . $entity->id());
$config->delete(); $config->delete();
} }
} }
...@@ -224,7 +230,7 @@ public function save(EntityInterface $entity) { ...@@ -224,7 +230,7 @@ public function save(EntityInterface $entity) {
*/ */
protected function doSave($id, EntityInterface $entity) { protected function doSave($id, EntityInterface $entity) {
$is_new = $entity->isNew(); $is_new = $entity->isNew();
$prefix = $this->getConfigPrefix(); $prefix = $this->getPrefix();
if ($id !== $entity->id()) { if ($id !== $entity->id()) {
// Renaming a config object needs to cater for: // Renaming a config object needs to cater for:
// - Storage needs to access the original object. // - Storage needs to access the original object.
...@@ -263,7 +269,7 @@ protected function mapToStorageRecord(EntityInterface $entity) { ...@@ -263,7 +269,7 @@ protected function mapToStorageRecord(EntityInterface $entity) {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function has($id, EntityInterface $entity) { protected function has($id, EntityInterface $entity) {
$prefix = $this->getConfigPrefix(); $prefix = $this->getPrefix();
$config = $this->configFactory->get($prefix . $id); $config = $this->configFactory->get($prefix . $id);
return !$config->isNew(); return !$config->isNew();
} }
......
...@@ -15,14 +15,6 @@ ...@@ -15,14 +15,6 @@
*/ */
interface ConfigEntityStorageInterface extends EntityStorageInterface { 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. * Extracts the configuration entity ID from the full configuration name.
* *
......
...@@ -45,9 +45,6 @@ protected function setUp() { ...@@ -45,9 +45,6 @@ protected function setUp() {
public function testStorageMethods() { public function testStorageMethods() {
$entity_type = \Drupal::entityManager()->getDefinition('config_test'); $entity_type = \Drupal::entityManager()->getDefinition('config_test');
$expected = $entity_type->getConfigPrefix() . '.';
$this->assertIdentical($this->storage->getConfigPrefix(), $expected);
// Test the static extractID() method. // Test the static extractID() method.
$expected_id = 'test_id'; $expected_id = 'test_id';
$config_name = $entity_type->getConfigPrefix() . '.' . $expected_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