public function get_custom_links($custom_paths, $language)
 {
     $links = array();
     foreach ($custom_paths as $custom_path) {
         if ($custom_path['index']) {
             $links[] = SitemapGenerator::add_xml_link_markup(Url::fromUserInput($custom_path['path'], array('language' => $language, 'absolute' => TRUE))->toString(), $custom_path['priority']);
         }
     }
     return $links;
 }
 public function generate_all_sitemaps()
 {
     $this->generator->set_custom_links($this->config->get('custom'));
     $this->generator->set_entity_types($this->config->get('entity_types'));
     foreach (\Drupal::languageManager()->getLanguages() as $language) {
         $this->generator->set_sitemap_lang($language);
         $this->language = $language;
         $this->sitemap = $this->generator->generate_sitemap();
         $this->save_sitemap();
     }
 }
 /**
  * Form constructor.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  *
  * @return array
  *   The form structure.
  */
 public function buildForm(array $form, FormStateInterface $form_state, $name = null)
 {
     $sitemap = \Drupal::service('custom_sitemap.sitemap');
     $custom_links = $sitemap->get_custom_links();
     $form['#title'] = $this->t('Add new custom link');
     $form['name'] = array('#type' => 'textfield', '#title' => $this->t('Machine name'), '#description' => $this->t('A unique machine-readable name for this content type. It must only contain lowercase letters, numbers, and underscores.'), '#required' => TRUE);
     $form['path'] = array('#type' => 'textfield', '#title' => $this->t('Path'), '#required' => TRUE, '#default_value' => $name !== null && array_key_exists($name, $custom_links) ? $custom_links[$name]['path'] : null);
     $form['index'] = array('#type' => 'checkbox', '#title' => $this->t('Include in sitemap'), '#default_value' => $name !== null && array_key_exists($name, $custom_links) && $custom_links[$name]['index']);
     $form['priority'] = array('#type' => 'select', '#title' => $this->t('Priority'), '#options' => SitemapGenerator::get_priority_select_values(), '#default_value' => $name !== null && array_key_exists($name, $custom_links) ? $custom_links[$name]['priority'] : SitemapGenerator::PRIORITY_DEFAULT);
     $form = parent::buildForm($form, $form_state);
     $form['actions']['submit']['#value'] = $this->t('Save link');
     return $form;
 }
 public function get_entity_links($entity_type, $bundles, $language)
 {
     foreach ($bundles as $bundle => $bundle_settings) {
         if (!$bundle_settings['index']) {
             continue;
         }
         $links = $this->get_entity_bundle_links($entity_type, $bundle, $language);
         foreach ($links as &$link) {
             $link = SitemapGenerator::add_xml_link_markup($link, $bundle_settings['priority']);
         }
         $this->entity_links = array_merge($this->entity_links, $links);
     }
     return $this->entity_links;
 }
 /**
  * @param array $form
  * @param string $entity_type
  * @param Vocabulary[] | NodeType[] $items
  * @param array $config
  */
 private function setEntityTypeDetailForm(&$form, $entity_type, $items, $config)
 {
     foreach ($items as $machine_name => $item) {
         $form[$entity_type]["{$entity_type}-{$machine_name}"] = array('#type' => 'fieldset', '#title' => $item->label(), "{$entity_type}-{$machine_name}-index" => array('#type' => 'checkbox', '#title' => $this->t('Include in sitemap'), '#default_value' => array_key_exists($machine_name, $config) && $config[$machine_name]['index'] == 1), "{$entity_type}-{$machine_name}-priority" => array('#type' => 'select', '#title' => $this->t('Priority'), '#options' => SitemapGenerator::get_priority_select_values(), '#default_value' => array_key_exists($machine_name, $config) ? $config[$machine_name]['priority'] : SitemapGenerator::PRIORITY_DEFAULT));
     }
 }