You are here

public function VariantPluginConfigureBlockFormBase::submitForm in Page Manager 8.4

Same name and namespace in other branches
  1. 8 page_manager_ui/src/Form/VariantPluginConfigureBlockFormBase.php \Drupal\page_manager_ui\Form\VariantPluginConfigureBlockFormBase::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

page_manager_ui/src/Form/VariantPluginConfigureBlockFormBase.php, line 167

Class

VariantPluginConfigureBlockFormBase
Provides a base form for configuring a block as part of a variant.

Namespace

Drupal\page_manager_ui\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $settings = (new FormState())
    ->setValues($form_state
    ->getValue('settings'));

  // Call the plugin submit handler.
  $this->block
    ->submitConfigurationForm($form, $settings);

  // Update the original form values.
  $form_state
    ->setValue('settings', $settings
    ->getValues());
  if ($this->block instanceof ContextAwarePluginInterface) {
    $this->block
      ->setContextMapping($form_state
      ->getValue('context_mapping', []));
  }
  $this
    ->getVariantPlugin()
    ->updateBlock($this->block
    ->getConfiguration()['uuid'], [
    'region' => $form_state
      ->getValue('region'),
  ]);
  $cached_values = $this
    ->getTempstore()
    ->get($form_state
    ->get('variant_id'));
  $cached_values['plugin'] = $this
    ->getVariantPlugin();
  $this
    ->getTempstore()
    ->set($form_state
    ->get('variant_id'), $cached_values);
}