function ConfigSingleExportForm::updateExport
Handles switching the export textarea.
1 call to ConfigSingleExportForm::updateExport()
- ConfigSingleExportForm::buildForm in core/
modules/ config/ src/ Form/ ConfigSingleExportForm.php - Form constructor.
File
-
core/
modules/ config/ src/ Form/ ConfigSingleExportForm.php, line 175
Class
- ConfigSingleExportForm
- Provides a form for exporting a single configuration file.
Namespace
Drupal\config\FormCode
public function updateExport($form, string $config_type, string $config_name) {
// Determine the full config name for the selected config entity.
// Calling this in the main form build requires accounting for not yet
// having input.
if (!empty($config_type) && $config_type !== 'system.simple') {
$definition = $this->entityTypeManager
->getDefinition($config_type);
$name = $definition->getConfigPrefix() . '.' . $config_name;
}
else {
$name = $config_name;
}
// Read the raw data for this config name, encode it, and display it.
$exists = $this->configStorage
->exists($name);
$form['export']['#value'] = !$exists ? NULL : Yaml::encode($this->configStorage
->read($name));
$form['export']['#description'] = !$exists ? NULL : $this->t('Filename: %name', [
'%name' => $name . '.yml',
]);
return $form['export'];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.