protected function ConfigSingleExportForm::findConfiguration in Drupal 8
Same name and namespace in other branches
- 9 core/modules/config/src/Form/ConfigSingleExportForm.php \Drupal\config\Form\ConfigSingleExportForm::findConfiguration()
Handles switching the configuration type selector.
2 calls to ConfigSingleExportForm::findConfiguration()
- ConfigSingleExportForm::buildForm in core/
modules/ config/ src/ Form/ ConfigSingleExportForm.php - Form constructor.
- ConfigSingleExportForm::updateConfigurationType in core/
modules/ config/ src/ Form/ ConfigSingleExportForm.php - Handles switching the configuration type selector.
File
- core/
modules/ config/ src/ Form/ ConfigSingleExportForm.php, line 171
Class
- ConfigSingleExportForm
- Provides a form for exporting a single configuration file.
Namespace
Drupal\config\FormCode
protected function findConfiguration($config_type) {
$names = [
'' => $this
->t('- Select -'),
];
// For a given entity type, load all entities.
if ($config_type && $config_type !== 'system.simple') {
$entity_storage = $this->entityTypeManager
->getStorage($config_type);
foreach ($entity_storage
->loadMultiple() as $entity) {
$entity_id = $entity
->id();
if ($label = $entity
->label()) {
$names[$entity_id] = new TranslatableMarkup('@label (@id)', [
'@label' => $label,
'@id' => $entity_id,
]);
}
else {
$names[$entity_id] = $entity_id;
}
}
}
else {
// Gather the config entity prefixes.
$config_prefixes = array_map(function (EntityTypeInterface $definition) {
return $definition
->getConfigPrefix() . '.';
}, $this->definitions);
// Find all config, and then filter our anything matching a config prefix.
$names = $this->configStorage
->listAll();
$names = array_combine($names, $names);
foreach ($names as $config_name) {
foreach ($config_prefixes as $config_prefix) {
if (strpos($config_name, $config_prefix) === 0) {
unset($names[$config_name]);
}
}
}
}
return $names;
}