You are here

public function FeedForm::save in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/aggregator/src/FeedForm.php \Drupal\aggregator\FeedForm::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/aggregator/src/FeedForm.php, line 22
Contains \Drupal\aggregator\FeedForm.

Class

FeedForm
Form controller for the aggregator feed edit forms.

Namespace

Drupal\aggregator

Code

public function save(array $form, FormStateInterface $form_state) {
  $feed = $this->entity;
  $insert = (bool) $feed
    ->id();
  $feed
    ->save();
  if ($insert) {
    drupal_set_message($this
      ->t('The feed %feed has been updated.', array(
      '%feed' => $feed
        ->label(),
    )));
    $form_state
      ->setRedirectUrl($feed
      ->urlInfo('canonical'));
  }
  else {
    $this
      ->logger('aggregator')
      ->notice('Feed %feed added.', array(
      '%feed' => $feed
        ->label(),
      'link' => $this
        ->l($this
        ->t('View'), new Url('aggregator.admin_overview')),
    ));
    drupal_set_message($this
      ->t('The feed %feed has been added.', array(
      '%feed' => $feed
        ->label(),
    )));
  }
}