You are here

public function AssemblerForm::submitForm in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.5

Same name and namespace in other branches
  1. 8.8 src/Form/AssemblerForm.php \Drupal\varbase\Form\AssemblerForm::submitForm()
  2. 8.4 src/Form/AssemblerForm.php \Drupal\varbase\Form\AssemblerForm::submitForm()
  3. 8.6 src/Form/AssemblerForm.php \Drupal\varbase\Form\AssemblerForm::submitForm()
  4. 8.7 src/Form/AssemblerForm.php \Drupal\varbase\Form\AssemblerForm::submitForm()
  5. 9.0.x src/Form/AssemblerForm.php \Drupal\varbase\Form\AssemblerForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/AssemblerForm.php, line 244

Class

AssemblerForm
Defines form for selecting extra components for the assembler to install.

Namespace

Drupal\varbase\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Extra Features.
  $extraFeatures = ConfigBit::getList('configbit/extra.components.varbase.bit.yml', 'show_extra_components', TRUE, 'dependencies', 'profile', 'varbase');
  if (count($extraFeatures)) {
    $extra_features_values = [];
    foreach ($extraFeatures as $extra_feature_key => $extra_feature_info) {

      // If form state has got value for this extra feature.
      if ($form_state
        ->hasValue($extra_feature_key)) {
        $extra_features_values[$extra_feature_key] = $form_state
          ->getValue($extra_feature_key);
      }
      if (isset($extra_feature_info['config_form']) && $extra_feature_info['config_form'] == TRUE) {
        $formbit_file_name = drupal_get_path('profile', 'varbase') . '/' . $extra_feature_info['formbit'];
        if (file_exists($formbit_file_name)) {
          include_once $formbit_file_name;
          $extra_features_editable_configs = call_user_func_array($extra_feature_key . "_get_editable_config_names", array());
          if (count($extra_features_editable_configs)) {
            foreach ($extra_features_editable_configs as $extra_features_editable_config_key => $extra_features_editable_config) {
              foreach ($extra_features_editable_config as $extra_features_config_item_key => $extra_features_config_item_value) {
                if ($form_state
                  ->hasValue($extra_features_config_item_key)) {
                  $extra_features_editable_configs[$extra_features_editable_config_key][$extra_features_config_item_key] = $form_state
                    ->getValue($extra_features_config_item_key);
                }
              }
            }
          }
          $GLOBALS['install_state']['varbase']['extra_features_configs'] = $extra_features_editable_configs;
        }
      }
    }
    $GLOBALS['install_state']['varbase']['extra_features_values'] = $extra_features_values;
  }

  // Demo Content.
  $demoContent = ConfigBit::getList('configbit/demo.content.varbase.bit.yml', 'show_demo', TRUE, 'dependencies', 'profile', 'varbase');
  if (count($demoContent)) {
    $demo_content_values = [];
    foreach ($demoContent as $demo_content_key => $demo_content_info) {

      // If form state has got value for this demo content.
      if ($form_state
        ->hasValue($demo_content_key)) {
        $demo_content_values[$demo_content_key] = $form_state
          ->getValue($demo_content_key);
      }
      if (isset($demo_content_info['config_form']) && $demo_content_info['config_form'] == TRUE) {
        $formbit_file_name = drupal_get_path('profile', 'varbase') . '/' . $demo_content_info['formbit'];
        if (file_exists($formbit_file_name)) {
          include_once $formbit_file_name;
          $demo_content_editable_configs = call_user_func_array($demo_content_key . "_get_editable_config_names", array());
          if (count($demo_content_editable_configs)) {
            foreach ($demo_content_editable_configs as $demo_content_editable_config_key => $demo_content_editable_config) {
              foreach ($demo_content_editable_config as $demo_content_config_item_key => $demo_content_config_item_value) {
                if ($form_state
                  ->hasValue($demo_content_config_item_key)) {
                  $demo_content_editable_configs[$demo_content_editable_config_key][$demo_content_config_item_key] = $form_state
                    ->getValue($demo_content_config_item_key);
                }
              }
            }
          }
          $GLOBALS['install_state']['varbase']['demo_content_configs'] = $demo_content_editable_configs;
        }
      }
    }
    $GLOBALS['install_state']['varbase']['demo_content_values'] = $demo_content_values;
  }
}