function DefaultProcessor::buildConfigurationForm
Same name in other branches
- 9 core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php \Drupal\aggregator\Plugin\aggregator\processor\DefaultProcessor::buildConfigurationForm()
Overrides PluginFormInterface::buildConfigurationForm
File
-
core/
modules/ aggregator/ src/ Plugin/ aggregator/ processor/ DefaultProcessor.php, line 117
Class
- DefaultProcessor
- Defines a default processor implementation.
Namespace
Drupal\aggregator\Plugin\aggregator\processorCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$config = $this->config('aggregator.settings');
$processors = $config->get('processors');
$info = $this->getPluginDefinition();
$counts = [
3,
5,
10,
15,
20,
25,
];
$items = array_map(function ($count) {
return $this->formatPlural($count, '1 item', '@count items');
}, array_combine($counts, $counts));
$intervals = [
3600,
10800,
21600,
32400,
43200,
86400,
172800,
259200,
604800,
1209600,
2419200,
4838400,
9676800,
];
$period = array_map([
$this->dateFormatter,
'formatInterval',
], array_combine($intervals, $intervals));
$period[FeedStorageInterface::CLEAR_NEVER] = t('Never');
$form['processors'][$info['id']] = [];
// Only wrap into details if there is a basic configuration.
if (isset($form['basic_conf'])) {
$form['processors'][$info['id']] = [
'#type' => 'details',
'#title' => t('Default processor settings'),
'#description' => $info['description'],
'#open' => in_array($info['id'], $processors),
];
}
$form['processors'][$info['id']]['aggregator_summary_items'] = [
'#type' => 'select',
'#title' => t('Number of items shown in listing pages'),
'#default_value' => $config->get('source.list_max'),
'#empty_value' => 0,
'#options' => $items,
];
$form['processors'][$info['id']]['aggregator_clear'] = [
'#type' => 'select',
'#title' => t('Discard items older than'),
'#default_value' => $config->get('items.expire'),
'#options' => $period,
'#description' => t('Requires a correctly configured <a href=":cron">cron maintenance task</a>.', [
':cron' => Url::fromRoute('system.status')->toString(),
]),
];
$lengths = [
0,
200,
400,
600,
800,
1000,
1200,
1400,
1600,
1800,
2000,
];
$options = array_map(function ($length) {
return $length == 0 ? t('Unlimited') : $this->formatPlural($length, '1 character', '@count characters');
}, array_combine($lengths, $lengths));
$form['processors'][$info['id']]['aggregator_teaser_length'] = [
'#type' => 'select',
'#title' => t('Length of trimmed description'),
'#default_value' => $config->get('items.teaser_length'),
'#options' => $options,
'#description' => t('The maximum number of characters used in the trimmed version of content.'),
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.