function ConfigSingleExportForm::updateExport

Same name and namespace in other branches
  1. 9 core/modules/config/src/Form/ConfigSingleExportForm.php \Drupal\config\Form\ConfigSingleExportForm::updateExport()
  2. 8.9.x core/modules/config/src/Form/ConfigSingleExportForm.php \Drupal\config\Form\ConfigSingleExportForm::updateExport()
  3. 10 core/modules/config/src/Form/ConfigSingleExportForm.php \Drupal\config\Form\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 146

Class

ConfigSingleExportForm
Provides a form for exporting a single configuration file.

Namespace

Drupal\config\Form

Code

public function updateExport($form, FormStateInterface $form_state) {
    // Determine the full config name for the selected config entity.
    if ($form_state->getValue('config_type') !== 'system.simple') {
        $definition = $this->entityTypeManager
            ->getDefinition($form_state->getValue('config_type'));
        $name = $definition->getConfigPrefix() . '.' . $form_state->getValue('config_name');
    }
    else {
        $name = $form_state->getValue('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.