public function OpmlFeedAdd::buildForm in Drupal 8
Same name and namespace in other branches
- 9 core/modules/aggregator/src/Form/OpmlFeedAdd.php \Drupal\aggregator\Form\OpmlFeedAdd::buildForm()
Form constructor.
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
array The form structure.
Overrides FormInterface::buildForm
File
- core/
modules/ aggregator/ src/ Form/ OpmlFeedAdd.php, line 68
Class
- OpmlFeedAdd
- Imports feeds from OPML.
Namespace
Drupal\aggregator\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$intervals = [
900,
1800,
3600,
7200,
10800,
21600,
32400,
43200,
64800,
86400,
172800,
259200,
604800,
1209600,
2419200,
];
$period = array_map([
\Drupal::service('date.formatter'),
'formatInterval',
], array_combine($intervals, $intervals));
$form['upload'] = [
'#type' => 'file',
'#title' => $this
->t('OPML File'),
'#description' => $this
->t('Upload an OPML file containing a list of feeds to be imported.'),
];
$form['remote'] = [
'#type' => 'url',
'#title' => $this
->t('OPML Remote URL'),
'#maxlength' => 1024,
'#description' => $this
->t('Enter the URL of an OPML file. This file will be downloaded and processed only once on submission of the form.'),
];
$form['refresh'] = [
'#type' => 'select',
'#title' => $this
->t('Update interval'),
'#default_value' => 3600,
'#options' => $period,
'#description' => $this
->t('The length of time between feed updates. Requires a correctly configured <a href=":cron">cron maintenance task</a>.', [
':cron' => Url::fromRoute('system.status')
->toString(),
]),
];
$form['actions'] = [
'#type' => 'actions',
];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Import'),
];
return $form;
}