From: Vincent Vanwaelscappel Date: Thu, 19 Mar 2020 10:35:55 +0000 (+0100) Subject: wip #3514 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=82662581f68d5e2b704ffa1572dfe8fb45ef484b;p=cubist_cms-back.git wip #3514 @0.5 --- diff --git a/src/app/Http/Controllers/CubistSEOController.php b/src/app/Http/Controllers/CubistSEOController.php index 8e06aea..973ae3e 100644 --- a/src/app/Http/Controllers/CubistSEOController.php +++ b/src/app/Http/Controllers/CubistSEOController.php @@ -11,14 +11,27 @@ use Illuminate\Http\Request; class CubistSEOController extends CubistFrontController { + protected function isRobotsEnabled() + { + if (!config('cubist.seo_robots', true)) { + return false; + } + $robots = $this->data['global']->get('robots'); + if (null === $robots) { + return false; + } + return in_array(env('APP_ENV'), $robots, true); + } + public function robots(Request $request) { $response = ['User-agent: *']; - if (config('cubist.seo_robots', true)) { + + if (!$this->isRobotsEnabled()) { + $response[] = 'Disallow: /'; + } else { $response[] = 'Disallow: /admin/'; $response[] = 'Sitemap: ' . url('/sitemap.xml'); - } else { - $response[] = 'Disallow: /'; } return response(implode("\n", $response))->header('Content-type', 'text/plain'); @@ -30,7 +43,7 @@ class CubistSEOController extends CubistFrontController $res = '' . "\n"; $res .= '' . "\n"; - if (true || config('cubist.seo_robots', true)) { + if ($this->isRobotsEnabled()) { $pages = Menu::getAllNavigablePages(); foreach ($pages as $url => $page) { if ($page instanceof PageItem && !$page->isRobots()) {