public function SimplesitemapVariantsForm::buildForm in Simple XML sitemap 8.3
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/ SimplesitemapVariantsForm.php, line 24
Class
- SimplesitemapVariantsForm
- Class SimplesitemapVariantsForm @package Drupal\simple_sitemap\Form
Namespace
Drupal\simple_sitemap\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form['simple_sitemap_variants'] = [
'#title' => $this
->t('Sitemap variants'),
'#type' => 'fieldset',
'#markup' => '<div class="description">' . $this
->t('Define sitemap variants. A sitemap variant is a sitemap instance of a certain type (specific sitemap generator and URL generators) accessible under a certain URL.<br>Each variant can have its own entity bundle settings (to be defined on bundle edit pages).') . '</div>',
'#prefix' => FormHelper::getDonationText(),
];
$form['simple_sitemap_variants']['variants'] = [
'#type' => 'textarea',
'#title' => $this
->t('Variants'),
'#default_value' => $this
->variantsToString($this->generator
->getSitemapManager()
->getSitemapVariants(NULL, TRUE)),
'#description' => $this
->t("Please specify sitemap variants, one per line. <strong>Caution: </strong>Removing variants here will delete their bundle settings, custom links and corresponding sitemap instances.<br><br>A variant definition consists of the variant name (used as the variant's path), the sitemap type it belongs to (optional) and the variant label (optional). These three values have to be separated by the | pipe | symbol.<br><br><strong>Examples:</strong><br><em>default | default_hreflang | Default</em> -> variant of the <em>default_hreflang</em> sitemap type and <em>Default</em> as label; accessible under <em>/default/sitemap.xml</em><br><em>test</em> -> variant of the <em>@default_sitemap_type</em> sitemap type and <em>test</em> as label; accessible under <em>/test/sitemap.xml</em><br><br><strong>Available sitemap types:</strong>", [
'@default_sitemap_type' => SimplesitemapManager::DEFAULT_SITEMAP_TYPE,
]),
];
foreach ($this->generator
->getSitemapManager()
->getSitemapTypes() as $sitemap_type => $definition) {
$form['simple_sitemap_variants']['variants']['#description'] .= '<br>' . '<em>' . $sitemap_type . '</em>' . (!empty($definition['description']) ? ': ' . $definition['description'] : '');
}
$this->formHelper
->displayRegenerateNow($form['simple_sitemap_custom']);
return parent::buildForm($form, $form_state);
}