From a51c5303569614540e428ee24be2baaf65cc1ea4 Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Thu, 26 Nov 2015 11:43:54 +0000 Subject: [PATCH] Issue #2587149 by Dane Powell, claudiu.cristea: Single item config export names are ambiguous --- core/modules/config/src/Form/ConfigSingleExportForm.php | 9 +++++++-- .../config/src/Tests/ConfigSingleImportExportTest.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/modules/config/src/Form/ConfigSingleExportForm.php b/core/modules/config/src/Form/ConfigSingleExportForm.php index 2426b9038d9f..d278e790c657 100644 --- a/core/modules/config/src/Form/ConfigSingleExportForm.php +++ b/core/modules/config/src/Form/ConfigSingleExportForm.php @@ -14,6 +14,7 @@ use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormState; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -169,8 +170,12 @@ class ConfigSingleExportForm extends FormBase { $entity_storage = $this->entityManager->getStorage($config_type); foreach ($entity_storage->loadMultiple() as $entity) { $entity_id = $entity->id(); - $label = $entity->label() ?: $entity_id; - $names[$entity_id] = $label; + if ($label = $entity->label()) { + $names[$entity_id] = new TranslatableMarkup('@label (@id)', ['@label' => $label, '@id' => $entity_id]); + } + else { + $names[$entity_id] = $entity_id; + } } } // Handle simple configuration. diff --git a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php index 817bf2298434..f08c7bd71970 100644 --- a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php +++ b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php @@ -208,7 +208,7 @@ EOD; $this->assertFieldByXPath('//select[@name="config_type"]//option[@selected="selected"]', t('Date format'), 'The date format entity type is selected when specified in the URL.'); $this->drupalGet('admin/config/development/configuration/single/export/date_format/fallback'); - $this->assertFieldByXPath('//select[@name="config_name"]//option[@selected="selected"]', t('Fallback date format'), 'The fallback date format config entity is selected when specified in the URL.'); + $this->assertFieldByXPath('//select[@name="config_name"]//option[@selected="selected"]', t('Fallback date format (fallback)'), 'The fallback date format config entity is selected when specified in the URL.'); $fallback_date = \Drupal::entityManager()->getStorage('date_format')->load('fallback'); $data = Yaml::encode($fallback_date->toArray());