You are here

public function ConfigSplitEntityForm::submitForm in Configuration Split 8

Same name and namespace in other branches
  1. 2.0.x src/Form/ConfigSplitEntityForm.php \Drupal\config_split\Form\ConfigSplitEntityForm::submitForm()

This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state can be updated, this way the subsequently invoked handlers can retrieve a regular entity object to act on. Generally this method should not be overridden unless the entity requires the same preparation for two actions, see \Drupal\comment\CommentForm for an example with the save and preview actions.

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 EntityForm::submitForm

File

src/Form/ConfigSplitEntityForm.php, line 241

Class

ConfigSplitEntityForm
The entity form.

Namespace

Drupal\config_split\Form

Code

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

  // Transform the values from the form to correctly save the entity.
  $extensions = $this
    ->config('core.extension');

  // Add the configs modules so we can save inactive splits.
  $module_list = $extensions
    ->get('module') + $this->entity
    ->get('module');
  $moduleSelection = $this
    ->readValuesFromPicker($form_state
    ->getValue('module'));
  $form_state
    ->setValue('module', array_intersect_key($module_list, $moduleSelection));
  $themeSelection = $this
    ->readValuesFromPicker($form_state
    ->getValue('theme'));
  $form_state
    ->setValue('theme', array_intersect_key($extensions
    ->get('theme'), $themeSelection));
  $blacklistSelection = $this
    ->readValuesFromPicker($form_state
    ->getValue('blacklist_picker'));
  $form_state
    ->setValue('blacklist', array_merge(array_keys($blacklistSelection), $this
    ->filterConfigNames($form_state
    ->getValue('blacklist_text'))));
  $graylistSelection = $this
    ->readValuesFromPicker($form_state
    ->getValue('graylist_picker'));
  $form_state
    ->setValue('graylist', array_merge(array_keys($graylistSelection), $this
    ->filterConfigNames($form_state
    ->getValue('graylist_text'))));
  parent::submitForm($form, $form_state);
}