/**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $generator = \Drupal::service('simple_sitemap.generator');
     $form['simple_sitemap_entities']['#prefix'] = $this->getDonationLink();
     $form['simple_sitemap_entities']['entities'] = ['#title' => $this->t('Sitemap entities'), '#type' => 'fieldset', '#markup' => '<p>' . $this->t("Simple XML sitemap settings will be added only to entity forms of entity types enabled here. For all entity types featuring bundles (e.g. <em>node</em>) sitemap settings have to be set on their bundle pages (e.g. <em>page</em>).") . '</p>'];
     $form['#attached']['library'][] = 'simple_sitemap/sitemapEntities';
     $form['#attached']['drupalSettings']['simple_sitemap'] = ['all_entities' => [], 'atomic_entities' => []];
     $entity_type_labels = [];
     foreach ($generator->getSitemapEntityTypes() as $entity_type_id => $entity_type) {
         $entity_type_labels[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;
     }
     asort($entity_type_labels);
     $f = \Drupal::service('simple_sitemap.form')->processForm($form_state);
     foreach ($entity_type_labels as $entity_type_id => $entity_type_label) {
         $form['simple_sitemap_entities']['entities'][$entity_type_id] = ['#type' => 'details', '#title' => $entity_type_label, '#open' => $generator->entityTypeIsEnabled($entity_type_id)];
         $form['simple_sitemap_entities']['entities'][$entity_type_id][$entity_type_id . '_enabled'] = ['#type' => 'checkbox', '#title' => $this->t('Enable @entity_type_label <em>(@entity_type_id)</em> support', ['@entity_type_label' => strtolower($entity_type_label), '@entity_type_id' => $entity_type_id]), '#description' => $this->t('Sitemap settings for this entity type can be set on its bundle pages and overridden on its entity pages.'), '#default_value' => $generator->entityTypeIsEnabled($entity_type_id)];
         $form['#attached']['drupalSettings']['simple_sitemap']['all_entities'][] = str_replace('_', '-', $entity_type_id);
         if ($generator->entityTypeIsAtomic($entity_type_id)) {
             $form['simple_sitemap_entities']['entities'][$entity_type_id][$entity_type_id . '_enabled']['#description'] = $this->t('Sitemap settings for this entity type can be set below and overridden on its entity pages.');
             $f->setEntityCategory('bundle')->setEntityTypeId($entity_type_id)->setBundleName($entity_type_id)->displayEntitySettings($form['simple_sitemap_entities']['entities'][$entity_type_id][$entity_type_id . '_settings'], TRUE);
             $form['#attached']['drupalSettings']['simple_sitemap']['atomic_entities'][] = str_replace('_', '-', $entity_type_id);
         }
     }
     $f->displayRegenerateNow($form['simple_sitemap_entities']['entities']);
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $generator = \Drupal::service('simple_sitemap.generator');
     $setting_string = '';
     foreach ($generator->getConfig('custom') as $custom_link) {
         $setting_string .= isset($custom_link['priority']) ? $custom_link['path'] . ' ' . Form::formatPriority($custom_link['priority']) : $custom_link['path'];
         $setting_string .= "\r\n";
     }
     $form['simple_sitemap_custom'] = ['#title' => $this->t('Custom links'), '#type' => 'fieldset', '#markup' => '<p>' . $this->t('Add custom internal drupal paths to the XML sitemap.') . '</p>', '#prefix' => $this->getDonationLink()];
     $form['simple_sitemap_custom']['custom_links'] = ['#type' => 'textarea', '#title' => $this->t('Relative Drupal paths'), '#default_value' => $setting_string, '#description' => $this->t("Please specify drupal internal (relative) paths, one per line. Do not forget to prepend the paths with a '/'. You can optionally add a priority (0.0 - 1.0) by appending it to the path after a space. The home page with the highest priority would be <em>/ 1.0</em>, the contact page with the default priority would be <em>/contact 0.5</em>.")];
     \Drupal::service('simple_sitemap.form')->displayRegenerateNow($form['simple_sitemap_custom']);
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $generator = \Drupal::service('simple_sitemap.generator');
     $form['simple_sitemap_settings']['#prefix'] = $this->getDonationLink();
     $form['simple_sitemap_settings']['regenerate'] = ['#title' => $this->t('Regenerate sitemap'), '#type' => 'fieldset', '#markup' => '<p>' . $this->t('This will regenerate the XML sitemap for all languages.') . '</p>'];
     $form['simple_sitemap_settings']['regenerate']['regenerate_submit'] = ['#type' => 'submit', '#value' => $this->t('Regenerate sitemap'), '#submit' => ['::generateSitemap'], '#validate' => []];
     $form['simple_sitemap_settings']['settings'] = ['#title' => $this->t('Settings'), '#type' => 'fieldset'];
     $form['simple_sitemap_settings']['settings']['cron_generate'] = ['#type' => 'checkbox', '#title' => $this->t('Regenerate the sitemap on every cron run'), '#description' => $this->t('Uncheck this if you intend to only regenerate the sitemap manually or via drush.'), '#default_value' => $generator->getSetting('cron_generate', TRUE)];
     $form['simple_sitemap_settings']['advanced'] = ['#title' => $this->t('Advanced settings'), '#type' => 'fieldset'];
     $form['simple_sitemap_settings']['advanced']['remove_duplicates'] = ['#type' => 'checkbox', '#title' => $this->t('Exclude duplicate links'), '#description' => $this->t('Uncheck this to significantly speed up the sitemap generation process on a huge site (more than 20 000 indexed entities).'), '#default_value' => $generator->getSetting('remove_duplicates', TRUE)];
     $form['simple_sitemap_settings']['advanced']['skip_untranslated'] = ['#type' => 'checkbox', '#title' => $this->t('Skip non-existent translations'), '#description' => $this->t('If checked, only links to the translated content will be included, otherwise the sitemap will include links to all content translation variants, even when the content has not been translated yet.'), '#default_value' => $generator->getSetting('skip_untranslated', FALSE)];
     $form['simple_sitemap_settings']['advanced']['max_links'] = ['#title' => $this->t('Maximum links in a sitemap'), '#description' => $this->t("The maximum number of links one sitemap can hold. If more links are generated than set here, a sitemap index will be created and the links split into several sub-sitemaps.<br/>50 000 links is the maximum Google will parse per sitemap, however it is advisable to set this to a lower number. If left blank, all links will be shown on a single sitemap."), '#type' => 'textfield', '#maxlength' => 5, '#size' => 5, '#default_value' => $generator->getSetting('max_links', 2000)];
     $form['simple_sitemap_settings']['advanced']['batch_process_limit'] = ['#title' => $this->t('Refresh batch every n links'), '#description' => $this->t("During sitemap generation, the batch process will issue a page refresh after n links processed to prevent PHP timeouts and memory exhaustion. Increasing this number will reduce the number of times Drupal has to bootstrap (thus speeding up the generation process), but will require more memory and less strict PHP timeout settings."), '#type' => 'textfield', '#maxlength' => 5, '#size' => 5, '#default_value' => $generator->getSetting('batch_process_limit', 1500), '#required' => TRUE];
     \Drupal::service('simple_sitemap.form')->displayRegenerateNow($form['simple_sitemap_settings']);
     return parent::buildForm($form, $form_state);
 }