public function SettingsForm::buildForm

Implements \Drupal\Core\Form\FormInterface::buildForm().

Overrides SystemConfigFormBase::buildForm

File

drupal/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php, line 87
Contains \Drupal\aggregator\Form\SettingsForm.

Class

SettingsForm
Configures aggregator settings for this site.

Namespace

Drupal\aggregator\Form

Code

public function buildForm(array $form, array &$form_state) {
  $config = $this->configFactory
    ->get('aggregator.settings');

  // Global aggregator settings.
  $form['aggregator_allowed_html_tags'] = array(
    '#type' => 'textfield',
    '#title' => t('Allowed HTML tags'),
    '#size' => 80,
    '#maxlength' => 255,
    '#default_value' => $config
      ->get('items.allowed_html'),
    '#description' => t('A space-separated list of HTML tags allowed in the content of feed items. Disallowed tags are stripped from the content.'),
  );

  // Only show basic configuration if there are actually options.
  $basic_conf = array();
  if (count($this->definitions['fetcher']) > 1) {
    $basic_conf['aggregator_fetcher'] = array(
      '#type' => 'radios',
      '#title' => t('Fetcher'),
      '#description' => t('Fetchers download data from an external source. Choose a fetcher suitable for the external source you would like to download from.'),
      '#options' => $this->definitions['fetcher'],
      '#default_value' => $config
        ->get('fetcher'),
    );
  }
  if (count($this->definitions['parser']) > 1) {
    $basic_conf['aggregator_parser'] = array(
      '#type' => 'radios',
      '#title' => t('Parser'),
      '#description' => t('Parsers transform downloaded data into standard structures. Choose a parser suitable for the type of feeds you would like to aggregate.'),
      '#options' => $this->definitions['parser'],
      '#default_value' => $config
        ->get('parser'),
    );
  }
  if (count($this->definitions['processor']) > 1) {
    $basic_conf['aggregator_processors'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Processors'),
      '#description' => t('Processors act on parsed feed data, for example they store feed items. Choose the processors suitable for your task.'),
      '#options' => $this->definitions['processor'],
      '#default_value' => $config
        ->get('processors'),
    );
  }
  if (count($basic_conf)) {
    $form['basic_conf'] = array(
      '#type' => 'details',
      '#title' => t('Basic configuration'),
      '#description' => t('For most aggregation tasks, the default settings are fine.'),
      '#collapsed' => FALSE,
    );
    $form['basic_conf'] += $basic_conf;
  }

  // Implementing processor plugins will expect an array at $form['processors'].
  $form['processors'] = array();

  // Call settingsForm() for each active processor.
  foreach ($this->definitions['processor'] as $id => $definition) {
    if (in_array($id, $config
      ->get('processors'))) {
      $form = $this->managers['processor']
        ->createInstance($id)
        ->settingsForm($form, $form_state);
    }
  }
  return parent::buildForm($form, $form_state);
}