You are here

public function MenuItemExtrasViewModesSettingsForm::save in Menu Item Extras 8.2

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/MenuItemExtrasViewModesSettingsForm.php, line 122

Class

MenuItemExtrasViewModesSettingsForm
Base form for menu view modes settings edit forms.

Namespace

Drupal\menu_item_extras

Code

public function save(array $form, FormStateInterface $form_state) {

  /** @var \Drupal\system\MenuInterface $menu */
  $menu = $this->entity;
  $status = $menu
    ->save();
  if ($status == SAVED_UPDATED) {
    $this
      ->messenger()
      ->addStatus($this
      ->t('Menu %label has been updated.', [
      '%label' => $menu
        ->label(),
    ]));
    $this
      ->logger('menu')
      ->notice('Menu %label has been updated.', [
      '%label' => $menu
        ->label(),
    ]);
  }
  $form_state
    ->setRedirectUrl($this->entity
    ->toUrl('view-modes-settings'));
}