function ConfigSingleExportForm::findConfiguration
Same name in other branches
- 9 core/modules/config/src/Form/ConfigSingleExportForm.php \Drupal\config\Form\ConfigSingleExportForm::findConfiguration()
- 8.9.x core/modules/config/src/Form/ConfigSingleExportForm.php \Drupal\config\Form\ConfigSingleExportForm::findConfiguration()
- 11.x 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 166
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('@id (@label)', [
'@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 (str_starts_with($config_name, $config_prefix)) {
unset($names[$config_name]);
}
}
}
}
return $names;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.