You are here

public function ShortcutForm::save in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/shortcut/src/ShortcutForm.php \Drupal\shortcut\ShortcutForm::save()

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

core/modules/shortcut/src/ShortcutForm.php, line 28
Contains \Drupal\shortcut\ShortcutForm.

Class

ShortcutForm
Form controller for the shortcut entity forms.

Namespace

Drupal\shortcut

Code

public function save(array $form, FormStateInterface $form_state) {
  $entity = $this->entity;
  $status = $entity
    ->save();
  if ($status == SAVED_UPDATED) {
    $message = $this
      ->t('The shortcut %link has been updated.', array(
      '%link' => $entity
        ->getTitle(),
    ));
  }
  else {
    $message = $this
      ->t('Added a shortcut for %title.', array(
      '%title' => $entity
        ->getTitle(),
    ));
  }
  drupal_set_message($message);
  $form_state
    ->setRedirect('entity.shortcut_set.customize_form', array(
    'shortcut_set' => $entity
      ->bundle(),
  ));
}