You are here

public function ImportConfirmForm::submitForm in Fixed Block Content 8

The submit handler for the confirm form.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: An associative array containing the current state of the form.

Overrides EntityForm::submitForm

File

src/Form/ImportConfirmForm.php, line 51

Class

ImportConfirmForm
Import default content confirm form class.

Namespace

Drupal\fixed_block_content\Form

Code

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

  // Import the current content block contents and store it into config.
  $this->entity
    ->importDefaultContent();
  $this->entity
    ->save();

  // Set a message that the entity was deleted.
  $this
    ->messenger()
    ->addMessage($this
    ->t('Current contents of block %label saved as the default content.', [
    '%label' => $this->entity
      ->label(),
  ]));

  // Redirect the user to the list controller when complete.
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}