cache->get('sitemap'))) { $xml = $this->generateSitemap(); Yii::$app->cache->set('sitemap', $xml, 3600 * 6); } Yii::$app->response->headers->add('Content-type', 'text/xml'); Yii::$app->response->send(); echo $xml; exit; } protected function generateSitemap() { $sitemap = new SitemapGenerator(); $this->processTickets($sitemap); return $sitemap->render(); } protected function processTickets(SitemapGenerator $sitemap) { $ticketQuery = Ticket::find()->where(['public' => 'y'])->asArray(); $urlManager = Yii::$app->urlManager; foreach ($ticketQuery->all() as $row) { if ($row['alias']) { $params = ['prop/view', 'alias' => $row['alias'], 'mode' => PropUrlRule::MODE_CLIENT]; foreach (LanguageHelper::$js2dbMap as $language) { $params['language'] = $language; $sitemap->addUrl($urlManager->createUrl($params), SitemapGenerator::DAILY, 0.5); } } } return $this; } }