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');
$res = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$res .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">' . "\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()) {