You are here

public function PageVariantAddWizard::finish in Page Manager 8

Same name and namespace in other branches
  1. 8.4 page_manager_ui/src/Wizard/PageVariantAddWizard.php \Drupal\page_manager_ui\Wizard\PageVariantAddWizard::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 EntityFormWizardBase::finish

File

page_manager_ui/src/Wizard/PageVariantAddWizard.php, line 178
Contains \Drupal\page_manager_ui\Wizard\PageVariantAddWizard.

Class

PageVariantAddWizard

Namespace

Drupal\page_manager_ui\Wizard

Code

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

  // Add the variant to the parent page tempstore.
  $page_tempstore = $this->tempstore
    ->get('page_manager.page')
    ->get($cached_values['page']
    ->id());
  $page_tempstore['page']
    ->addVariant($cached_values['page_variant']);
  $this->tempstore
    ->get('page_manager.page')
    ->set($cached_values['page']
    ->id(), $page_tempstore);
  $variant_plugin = $cached_values['page_variant']
    ->getVariantPlugin();
  drupal_set_message($this
    ->t('The %label @entity_type has been added to the page, but has not been saved. Please save the page to store changes.', array(
    '%label' => $cached_values['page_variant']
      ->label(),
    '@entity_type' => $variant_plugin
      ->adminLabel(),
  )));
  $form_state
    ->setRedirectUrl(new Url('entity.page.edit_form', [
    'machine_name' => $cached_values['page']
      ->id(),
    'step' => 'general',
  ]));
}