class RssFeedsForm

Configure RSS settings for this site.

Hierarchy

Expanded class hierarchy of RssFeedsForm

1 string reference to 'RssFeedsForm'
system.routing.yml in drupal/core/modules/system/system.routing.yml
drupal/core/modules/system/system.routing.yml

File

drupal/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php, line 15
Contains \Drupal\system\Form\RssFeedsForm.

Namespace

Drupal\system\Form
View source
class RssFeedsForm extends SystemConfigFormBase {

  /**
   * {@inheritdoc}
   */
  public function getFormID() {
    return 'system_rss_feeds_settings';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, array &$form_state) {
    $rss_config = $this->configFactory
      ->get('system.rss');
    $form['feed_description'] = array(
      '#type' => 'textarea',
      '#title' => t('Feed description'),
      '#default_value' => $rss_config
        ->get('channel.description'),
      '#description' => t('Description of your site, included in each feed.'),
    );
    $form['feed_default_items'] = array(
      '#type' => 'select',
      '#title' => t('Number of items in each feed'),
      '#default_value' => $rss_config
        ->get('items.limit'),
      '#options' => drupal_map_assoc(array(
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        10,
        15,
        20,
        25,
        30,
      )),
      '#description' => t('Default number of items to include in each feed.'),
    );
    $form['feed_item_length'] = array(
      '#type' => 'select',
      '#title' => t('Feed content'),
      '#default_value' => $rss_config
        ->get('items.view_mode'),
      '#options' => array(
        'title' => t('Titles only'),
        'teaser' => t('Titles plus teaser'),
        'fulltext' => t('Full text'),
      ),
      '#description' => t('Global setting for the default display of content items in each feed.'),
    );
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
    $this->configFactory
      ->get('system.rss')
      ->set('channel.description', $form_state['values']['feed_description'])
      ->set('items.limit', $form_state['values']['feed_default_items'])
      ->set('items.view_mode', $form_state['values']['feed_item_length'])
      ->save();
    parent::submitForm($form, $form_state);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RssFeedsForm::buildForm public function Implements \Drupal\Core\Form\FormInterface::buildForm(). Overrides SystemConfigFormBase::buildForm
RssFeedsForm::getFormID public function Returns a unique string identifying the form. Overrides FormInterface::getFormID
RssFeedsForm::submitForm public function Implements \Drupal\Core\Form\FormInterface::submitForm(). Overrides SystemConfigFormBase::submitForm
SystemConfigFormBase::$configFactory protected property Stores the configuration factory.
SystemConfigFormBase::create public static function Instantiates a new instance of this controller. Overrides ControllerInterface::create 9
SystemConfigFormBase::validateForm public function Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormInterface::validateForm 7
SystemConfigFormBase::__construct public function Constructs a \Drupal\system\SystemConfigFormBase object. 9