You are here

public function BrowserGroupsForm::save in Paragraphs Browser 8

Form submission handler for the 'save' action.

Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.

Parameters

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

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Overrides EntityForm::save

File

src/Form/BrowserGroupsForm.php, line 188
Contains \Drupal\paragraphs_browser\Form\BrowserGroupsForm.

Class

BrowserGroupsForm
Class CleanupUrlAliases.

Namespace

Drupal\paragraphs_browser\Form

Code

public function save(array $form, FormStateInterface $form_state) {
  $paragraphs_browser = $this->entity;
  $changes = TRUE;
  if ($paragraphs_browser instanceof UnsavedConfigurationInterface) {
    if ($paragraphs_browser
      ->hasChanges()) {
      $paragraphs_browser
        ->savePermanent();
    }
    else {
      $paragraphs_browser
        ->discardChanges();
      $changes = FALSE;
    }
  }
  else {
    $paragraphs_browser
      ->save();
  }
  if ($changes) {
    $this
      ->messenger()
      ->addStatus($this
      ->t('The changes were successfully saved.'));
  }
  else {
    $this
      ->messenger()
      ->addStatus($this
      ->t('No values were changed.'));
  }
  return SAVED_UPDATED;
}