summaryrefslogtreecommitdiffstats
path: root/core/modules/aggregator/src/FeedForm.php
blob: aed2cd19c359524676170345d471153c5bd762f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

namespace Drupal\aggregator;

use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

/**
 * Form handler for the aggregator feed edit forms.
 *
 * @internal
 */
class FeedForm extends ContentEntityForm {

  /**
   * {@inheritdoc}
   */
  public function save(array $form, FormStateInterface $form_state) {
    $feed = $this->entity;
    $status = $feed->save();
    $label = $feed->label();
    $view_link = $feed->link($label, 'canonical');
    if ($status == SAVED_UPDATED) {
      drupal_set_message($this->t('The feed %feed has been updated.', ['%feed' => $view_link]));
      $form_state->setRedirectUrl($feed->urlInfo('canonical'));
    }
    else {
      $this->logger('aggregator')->notice('Feed %feed added.', ['%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.', ['%feed' => $view_link]));
    }
  }

}