Example #1
0
 /**
  * Loads the cached form state.
  *
  * @param string $form_build_id
  *   The unique form build ID.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 protected function loadCachedFormState($form_build_id, FormStateInterface $form_state)
 {
     if ($stored_form_state = $this->keyValueExpirableFactory->get('form_state')->get($form_build_id)) {
         // Re-populate $form_state for subsequent rebuilds.
         $form_state->setFormState($stored_form_state);
         // If the original form is contained in include files, load the files.
         // @see \Drupal\Core\Form\FormStateInterface::loadInclude()
         $build_info = $form_state->getBuildInfo();
         $build_info += ['files' => []];
         foreach ($build_info['files'] as $file) {
             if (is_array($file)) {
                 $file += array('type' => 'inc', 'name' => $file['module']);
                 $this->moduleHandler->loadInclude($file['module'], $file['type'], $file['name']);
             } elseif (file_exists($file)) {
                 require_once $this->root . '/' . $file;
             }
         }
         // Retrieve the list of previously known safe strings and store it for
         // this request.
         // @todo Ensure we are not storing an excessively large string list
         //   in: https://www.drupal.org/node/2295823
         $build_info += ['safe_strings' => []];
         SafeMarkup::setMultiple($build_info['safe_strings']);
         unset($build_info['safe_strings']);
         $form_state->setBuildInfo($build_info);
     }
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function setBuildInfo(array $build_info)
 {
     $this->mainFormState->setBuildInfo($build_info);
     return $this;
 }
 public function submitForm(array &$form, FormStateInterface $form_state) {
   $build_info = $form_state->getBuildInfo();
   $build_info['args'][0]['parameters']['langcode'] = $form_state->getValue('langcode');
   $build_info['args'][0]['parameters']['langcodes'] = $form_state->getValue('langcodes');
   $form_state->setBuildInfo($build_info);
 }
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->_move_all_config_files_directory('general');
    $this->_move_all_config_files_directory('seven');
    $this->_move_all_config_files_directory('bfc_admin_theme');
    $this->_move_all_config_files_directory('bootstrap');
    $this->_move_all_config_files_directory('text_formats_editors');
    $this->_move_all_config_files_directory('user');
    $this->_move_all_config_files_directory('linkit');

    if(!empty($_GET['langcodes'])){
      # Enabled multilanguage modules
      $this->_move_all_config_files_directory('multilanguage');
    }

    if ($form_state->getValue('editor') == 1) {
      $this->_move_config_file('user.role.editor.yml', 'roles');
    }
    if ($form_state->getValue('administrator') == 1) {
      $this->_move_config_file('user.role.administrator.yml', 'roles');
    }
    if ($form_state->getValue('article') == 1) {
      $this->_move_all_config_files_directory('article');
    }
    if ($form_state->getValue('page') == 1) {
      $this->_move_all_config_files_directory('page');
    }

    $build_info = $form_state->getBuildInfo();
    $build_info['args'][0]['parameters']['configuration'] = TRUE;
    $form_state->setBuildInfo($build_info);
  }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $installModules = [];
     foreach ($form_state->getValues() as $key => $value) {
         if (strpos($key, 'install_modules') !== FALSE && $value) {
             preg_match('/install_modules_(?P<name>\\w+)/', $key, $values);
             $installModules[] = $values['name'];
         }
     }
     $buildInfo = $form_state->getBuildInfo();
     $install_state = $buildInfo['args'];
     $install_state[0]['thunder_additional_modules'] = $installModules;
     $install_state[0]['form_state_values'] = $form_state->getValues();
     $buildInfo['args'] = $install_state;
     $form_state->setBuildInfo($buildInfo);
 }
 /**
  * @covers ::setBuildInfo
  */
 public function testSetBuildInfo()
 {
     $build_info = ['FOO' => 'BAR'];
     $this->decoratedFormState->setBuildInfo($build_info)->shouldBeCalled();
     $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setBuildInfo($build_info));
 }