function WorkspacePublishForm::submitForm

Same name and namespace in other branches
  1. 10 core/modules/workspaces/src/Form/WorkspacePublishForm.php \Drupal\workspaces\Form\WorkspacePublishForm::submitForm()
  2. 11.x core/modules/workspaces/src/Form/WorkspacePublishForm.php \Drupal\workspaces\Form\WorkspacePublishForm::submitForm()

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');
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.