/** * Returns the whole sitemap, a requested sitemap chunk, or the sitemap index file. * * @param int $sitemap_id * Id of the sitemap chunk. * * @return object Response * Returns an XML response. */ public function get_sitemap($sitemap_id = NULL) { $sitemap = new Simplesitemap(); $output = $sitemap->get_sitemap($sitemap_id); // Display sitemap with correct xml header. return new Response($output, Response::HTTP_OK, array('content-type' => 'application/xml')); }
private function generate_entity_links() { foreach ($this->entity_types as $entity_type => $bundles) { $class_path = Simplesitemap::get_plugin_path($entity_type); if ($class_path !== FALSE) { require_once $class_path; $class_name = "Drupal\\simplesitemap\\LinkGenerators\\EntityTypeLinkGenerators\\{$entity_type}"; $link_generator = new $class_name(); $links = $link_generator->get_entity_links($entity_type, $bundles, $this->language); $this->links = array_merge($this->links, $links); } } }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $sitemap = new Simplesitemap(); $custom_links_string = str_replace("\r\n", "\n", $form_state->getValue('custom_links')); $custom_links_string_lines = array_filter(explode("\n", $custom_links_string), 'trim'); $custom_link_config = array(); foreach ($custom_links_string_lines as $line) { $line_settings = explode(' ', $line, 2); $custom_link_config[]['path'] = $line_settings[0]; if (isset($line_settings[1])) { end($custom_link_config); $key = key($custom_link_config); $custom_link_config[$key]['priority'] = number_format((double) $line_settings[1], 1, '.', ''); } } $sitemap->save_custom_links($custom_link_config); parent::submitForm($form, $form_state); // Regenerate sitemaps according to user setting. if ($form_state->getValue('simplesitemap_rebuild_now')) { $sitemap->generate_sitemap(); } }
public function rebuild_sitemap(array &$form, FormStateInterface $form_state) { $sitemap = new Simplesitemap(); $sitemap->generate_sitemap(); }