/** * @desc Tries to generate the sitemap.xml file and throws an exception if it can't be done. * @throws IOException */ public static function try_to_generate() { $sitemap = SitemapService::get_public_sitemap(); $export_config = self::get_export_config(); $file = new File(PATH_TO_ROOT . '/sitemap.xml'); $file->write($sitemap->export($export_config)->render()); self::update_last_generation_date(); }
public function execute(HTTPRequestCustom $request) { $sitemap = SitemapService::get_public_sitemap(); AppContext::get_response()->set_header('content-type', 'text/xml'); return new SiteNodisplayResponse($sitemap->export(SitemapXMLFileService::get_export_config())); }