You are here

public function WorkspacePublishForm::submitForm in Drupal 9

Same name and namespace in other branches
  1. 10 core/modules/workspaces/src/Form/WorkspacePublishForm.php \Drupal\workspaces\Form\WorkspacePublishForm::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

core/modules/workspaces/src/Form/WorkspacePublishForm.php, line 142

Class

WorkspacePublishForm
Provides the workspace publishing form.

Namespace

Drupal\workspaces\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $workspace = $this->workspace;
  try {
    $workspace
      ->publish();
    $this
      ->messenger()
      ->addMessage($this
      ->t('Successful publication.'));
  } catch (WorkspaceAccessException $e) {
    $this
      ->messenger()
      ->addMessage($e
      ->getMessage(), 'error');
  } catch (\Exception $e) {
    $this
      ->messenger()
      ->addMessage($this
      ->t('Publication failed. All errors have been logged.'), 'error');
  }
}