You are here

public function PanelsBlockConfigureFormBase::submitForm in Panels 8.3

Same name and namespace in other branches
  1. 8.4 src/Form/PanelsBlockConfigureFormBase.php \Drupal\panels\Form\PanelsBlockConfigureFormBase::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/PanelsBlockConfigureFormBase.php, line 170

Class

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

Namespace

Drupal\panels\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($settings
      ->getValue('context_mapping', []));
  }
  $configuration = $this->block
    ->getConfiguration();
  $configuration['region'] = $form_state
    ->getValue('region');
  $this
    ->getVariantPlugin()
    ->updateBlock($this->block
    ->getConfiguration()['uuid'], $configuration);
  $cached_values = $this
    ->getCachedValues($this->tempstore, $this->tempstore_id, $form_state
    ->get('machine_name'));
  $cached_values['plugin'] = $this
    ->getVariantPlugin();

  // PageManager specific handling.
  if (isset($cached_values['page_variant'])) {
    $cached_values['page_variant']
      ->getVariantPlugin()
      ->setConfiguration($cached_values['plugin']
      ->getConfiguration());
  }
  $this
    ->getTempstore()
    ->set($cached_values['id'], $cached_values);
}