public function byMysqlAction($param = null) { $domain = rtrim($this->config->application->siteUri, '/'); $sitemapsStorage = rtrim($this->config->application->sitemapsDir, '/'); $sitemap = new Sitemap($domain); $sitemap->setPath($sitemapsStorage . '/'); /** @var Contents[] $contents */ $contents = Contents::find(['columns' => "url, content, created_at", 'group' => "url", 'order' => "created_at DESC"]); $count = 0; foreach ($contents as $content) { $count++; if ($count % 1000 == 0) { $this->log->info("обрабатано {$count} строк"); } $data = json_decode($content->content, true); if (isset($param[3]) && $param[3] == 'full') { $condition = $data['controller'] == 'books' && ($data['action'] == 'listByClass' || $data['action'] == 'booksBySubject' || $data['action'] == 'listByBoth' || $data['action'] == 'view' || $data['action'] == 'list'); } else { $condition = $data['controller'] == 'books' && ($data['action'] == 'listByClass' || $data['action'] == 'booksBySubject' || $data['action'] == 'listByBoth' || $data['action'] == 'view'); } if ($condition) { $sitemap->addItem($content->url, 0.5, null, $content->created_at); continue; } if ($data['controller'] == 'books' && $data['action'] == 'viewTask' && $data['book']['is_single_page'] == false) { $sitemap->addItem($content->url, 0.5, null, $content->created_at); } } $sitemap->createSitemapIndex($domain . '/sitemaps/', 'Today'); }
protected function deleteContents() { /** @var Urls[] $urls */ $urls = Urls::find(['(type = :type1: OR type = :type2:) AND action = :action:', 'bind' => ['type1' => Urls::CONTENT, 'type2' => Urls::COMMON, 'action' => Urls::FOR_DELETING]]); foreach ($urls as $url) { $contentsForDeleting = Contents::find(['url = :url: AND type = :type:', 'bind' => ['url' => $url->url, 'type' => $url->type]]); $contentsForDeleting->delete(); $this->log->info("Удален контент url= . {$url->url}"); $url->delete(); } }