public function XmlSitemapRebuildForm::buildForm in XML sitemap 8
Same name and namespace in other branches
- 2.x src/Form/XmlSitemapRebuildForm.php \Drupal\xmlsitemap\Form\XmlSitemapRebuildForm::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 ConfigFormBase::buildForm
File
- src/
Form/ XmlSitemapRebuildForm.php, line 65
Class
- XmlSitemapRebuildForm
- Configure xmlsitemap settings for this site.
Namespace
Drupal\xmlsitemap\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$request = $this
->getRequest();
if (!$request->request && !$this->state
->get('xmlsitemap_rebuild_needed')) {
if (!$this->state
->get('xmlsitemap_regenerate_needed')) {
$this
->messenger()
->addError($this
->t('Your sitemap is up to date and does not need to be rebuilt.'));
}
else {
$request->query
->set('destination', 'admin/config/search/xmlsitemap');
$this
->messenger()
->addWarning($this
->t('A rebuild is not necessary. If you are just wanting to regenerate the XML sitemap files, you can <a href="@link-cron">run cron manually</a>.', [
'@link-cron' => Url::fromRoute('system.run_cron', [], [
'query' => $this
->getDestinationArray(),
]),
]));
$this
->setRequest($request);
}
}
// Build a list of rebuildable link types.
$rebuild_types = xmlsitemap_get_rebuildable_link_types();
$rebuild_types = array_combine($rebuild_types, $rebuild_types);
$form['entity_type_ids'] = [
'#type' => 'select',
'#title' => $this
->t('Select which link types you would like to rebuild'),
'#description' => $this
->t('If no link types are selected, the sitemap files will just be regenerated.'),
'#multiple' => TRUE,
'#options' => $rebuild_types,
'#default_value' => $this->state
->get('xmlsitemap_rebuild_needed') || !$this->state
->get('xmlsitemap_developer_mode') ? $rebuild_types : [],
'#access' => $this->state
->get('xmlsitemap_developer_mode'),
];
$form['save_custom'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Save and restore any custom inclusion and priority links.'),
'#default_value' => TRUE,
];
return parent::buildForm($form, $form_state);
}