You are here

public function WorkspaceUnarchiveForm::submitForm in Workspace 8

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/WorkspaceUnarchiveForm.php, line 105

Class

WorkspaceUnarchiveForm
Handle workspace unarchive on administrative pages.

Namespace

Drupal\workspace\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  try {
    $this->workspace
      ->setPublished()
      ->save();
    $form_state
      ->setRedirect('entity.workspace.collection');
  } catch (\Exception $e) {
    watchdog_exception('Workspace', $e);
    $this
      ->messenger()
      ->addError($e
      ->getMessage());
  }
  $this
    ->messenger()
    ->addStatus($this
    ->t('The %workspace workspace has been successfully unarchived.', [
    '%workspace' => $this->workspace
      ->label(),
  ]));
}