From 82662581f68d5e2b704ffa1572dfe8fb45ef484b Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 19 Mar 2020 11:35:55 +0100 Subject: [PATCH] wip #3514 @0.5 --- .../Http/Controllers/CubistSEOController.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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()) { -- 2.39.5