Issue #2587149 by Dane Powell, claudiu.cristea: Single item config export names are ambiguous

8.1.x
Nathaniel Catchpole 2015-11-26 11:43:54 +00:00
parent 1f504dd514
commit a51c530356
2 changed files with 8 additions and 3 deletions

View File

@ -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.

View File

@ -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());