You are here

public function PanelizerWizardBase::finish in Panelizer 8.3

Same name and namespace in other branches
  1. 8.5 src/Wizard/PanelizerWizardBase.php \Drupal\panelizer\Wizard\PanelizerWizardBase::finish()
  2. 8.4 src/Wizard/PanelizerWizardBase.php \Drupal\panelizer\Wizard\PanelizerWizardBase::finish()

Form submit handler for finalizing the wizard values.

If you need to generate an entity or save config or raw table data subsequent to your form wizard, this is the responsible method.

Parameters

array $form: Drupal form array.

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

Overrides FormWizardBase::finish

1 call to PanelizerWizardBase::finish()
PanelizerAddWizard::finish in src/Wizard/PanelizerAddWizard.php
Form submit handler for finalizing the wizard values.
1 method overrides PanelizerWizardBase::finish()
PanelizerAddWizard::finish in src/Wizard/PanelizerAddWizard.php
Form submit handler for finalizing the wizard values.

File

src/Wizard/PanelizerWizardBase.php, line 134

Class

PanelizerWizardBase

Namespace

Drupal\panelizer\Wizard

Code

public function finish(array &$form, FormStateInterface $form_state) {
  $cached_values = $form_state
    ->getTemporaryValue('wizard');

  // Save the panels display mode and its custom settings as third party
  // data of the display mode for this entity+bundle+display.

  /** @var \Drupal\panelizer\Panelizer $panelizer */
  $panelizer = \Drupal::service('panelizer');

  /** @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface $invalidator */
  $invalidator = \Drupal::service('cache_tags.invalidator');
  list($entity_type, $bundle, $view_mode, $display_id) = explode('__', $cached_values['id']);
  $panelizer
    ->setDefaultPanelsDisplay($display_id, $entity_type, $bundle, $view_mode, $cached_values['plugin']);
  $panelizer
    ->setDisplayStaticContexts($display_id, $entity_type, $bundle, $view_mode, $cached_values['contexts']);
  parent::finish($form, $form_state);
  $form_state
    ->setRedirect('panelizer.wizard.edit', [
    'machine_name' => $cached_values['id'],
  ]);
  $invalidator
    ->invalidateTags([
    "panelizer_default:{$entity_type}:{$bundle}:{$view_mode}:{$display_id}",
  ]);
}