public function XmlSitemapSettingsForm::validateForm in XML sitemap 8
Same name and namespace in other branches
- 2.x src/Form/XmlSitemapSettingsForm.php \Drupal\xmlsitemap\Form\XmlSitemapSettingsForm::validateForm()
Form validation handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormBase::validateForm
File
- src/
Form/ XmlSitemapSettingsForm.php, line 275
Class
- XmlSitemapSettingsForm
- Configure xmlsitemap settings for this site.
Namespace
Drupal\xmlsitemap\FormCode
public function validateForm(array &$form, FormStateInterface $form_state) {
// Check that the chunk size will not create more than 1000 chunks.
$chunk_size = $form_state
->getValue('chunk_size');
if ($chunk_size != 'auto' && $chunk_size != 50000 && xmlsitemap_get_link_count() / $chunk_size > 1000) {
$form_state
->setErrorByName('chunk_size', $this
->t('The sitemap page link count of @size will create more than 1,000 sitemap pages. Please increase the link count.', [
'@size' => $chunk_size,
]));
}
$base_url = $form_state
->getValue('xmlsitemap_base_url');
$base_url = rtrim($base_url, '/');
$form_state
->setValue('xmlsitemap_base_url', $base_url);
if ($base_url != '' && !UrlHelper::isValid($base_url, TRUE)) {
$form_state
->setErrorByName('xmlsitemap_base_url', $this
->t('Invalid base URL.'));
}
parent::validateForm($form, $form_state);
}