You are here

function _webform_form_config_single_export_form_update_export in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_devel/webform_devel.module \_webform_form_config_single_export_form_update_export()

Handles switching the export textarea and tidies exported MSK configuration.

Copied from: \Drupal\config\Form\ConfigSingleExportForm::updateExport.

1 string reference to '_webform_form_config_single_export_form_update_export'
webform_devel_form_config_single_export_form_alter in modules/webform_devel/webform_devel.module
Implements hook_form_FORM_ID_alter() for config single export form.

File

modules/webform_devel/webform_devel.module, line 69
Provides development tools Webform module.

Code

function _webform_form_config_single_export_form_update_export($form, FormStateInterface $form_state) {

  // Determine the full config name for the selected config entity.
  if ($form_state
    ->getValue('config_type') !== 'system.simple') {
    $definition = \Drupal::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.
  $value = Yaml::encode(\Drupal::service('config.storage')
    ->read($name));

  // Tidy all only Webform exported configuration…for now.
  if (strpos($name, 'webform') === 0) {
    $value = WebformYaml::tidy($value);
  }
  $form['export']['#type'] = 'webform_codemirror';
  $form['export']['#mode'] = 'yaml';
  $form['export']['#description'] = t('Filename: %name', [
    '%name' => $name . '.yml',
  ]);
  $form['export']['#value'] = $value;
  return $form['export'];
}