99
1010class SitemapController extends Controller
1111{
12+ public function __construct (public Sitemap $ sitemap ) {}
13+
1214 public function index ()
1315 {
1416 abort_unless (config ('statamic.seo-pro.sitemap.enabled ' ), 404 );
1517
16- $ key = request ()->getHttpHost ();
1718 $ cacheUntil = Carbon::now ()->addMinutes (config ('statamic.seo-pro.sitemap.expire ' ));
19+ $ cacheKey = implode ('_ ' , [Sitemap::CACHE_KEY , request ()->getHttpHost (), $ this ->sitemap ->sites ()->map ->handle ()->join ('' )]);
1820
1921 if (config ('statamic.seo-pro.sitemap.pagination.enabled ' , false )) {
20- $ content = Cache::remember (Sitemap:: CACHE_KEY . ' _ ' . $ key . ' _index ' , $ cacheUntil , function () {
22+ $ content = Cache::remember ("{ $ cacheKey } _index " , $ cacheUntil , function () {
2123 return view ('seo-pro::sitemap_index ' , [
2224 'xml_header ' => '<?xml version="1.0" encoding="UTF-8"?> ' ,
23- 'sitemaps ' => app (Sitemap::class) ->paginatedSitemaps (),
25+ 'sitemaps ' => $ this -> sitemap ->paginatedSitemaps (),
2426 ])->render ();
2527 });
2628 } else {
27- $ content = Cache::remember (Sitemap:: CACHE_KEY . ' _ ' . $ key , $ cacheUntil , function () {
29+ $ content = Cache::remember ($ cacheKey , $ cacheUntil , function () {
2830 return view ('seo-pro::sitemap ' , [
2931 'xml_header ' => '<?xml version="1.0" encoding="UTF-8"?> ' ,
30- 'pages ' => app (Sitemap::class) ->pages (),
32+ 'pages ' => $ this -> sitemap ->pages (),
3133 ])->render ();
3234 });
3335 }
@@ -42,11 +44,10 @@ public function show($page)
4244 abort_unless (filter_var ($ page , FILTER_VALIDATE_INT ), 404 );
4345
4446 $ cacheUntil = Carbon::now ()->addMinutes (config ('statamic.seo-pro.sitemap.expire ' ));
45-
46- $ cacheKey = Sitemap::CACHE_KEY .'_ ' .$ page ;
47+ $ cacheKey = implode ('_ ' , [Sitemap::CACHE_KEY , $ page , request ()->getHttpHost (), $ this ->sitemap ->sites ()->map ->handle ()->join ('' )]);
4748
4849 $ content = Cache::remember ($ cacheKey , $ cacheUntil , function () use ($ page ) {
49- abort_if (empty ($ pages = app (Sitemap::class) ->paginatedPages ($ page )), 404 );
50+ abort_if (empty ($ pages = $ this -> sitemap ->paginatedPages ($ page )), 404 );
5051
5152 return view ('seo-pro::sitemap ' , [
5253 'xml_header ' => '<?xml version="1.0" encoding="UTF-8"?> ' ,
0 commit comments