get('/language/{locale}/', $this->call('setLocale')) ->bind('set_locale'); $controllers ->get('/', $this->call('getRoot')) ->bind('root'); $controllers ->get('/robots.txt', $this->call('getRobots')) ->bind('robots'); return $controllers; } public function getRobots(Application $app, Request $request) { if ($app['phraseanet.registry']->get('GV_allow_search_engine') === true) { $buffer = "User-Agent: *\n" . "Allow: /\n"; } else { $buffer = "User-Agent: *\n" . "Disallow: /\n"; } return new Response($buffer, 200, array('Content-Type' => 'text/plain')); } public function getRoot(Application $app, Request $request) { if ($app['browser']->isMobile()) { return $app->redirect("/login/?redirect=lightbox"); } elseif ($app['browser']->isNewGeneration()) { return $app->redirect("/login/?redirect=prod"); } return $app->redirect("/login/?redirect=client"); } public function setLocale(Application $app, Request $request, $locale) { $redirect = $request->query->get('redirect') ? : $app->path('root'); $response = $app->redirect($redirect); $response->headers->setCookie(new Cookie('locale', $locale)); return $response; } /** * Prefix the method to call with the controller class name * * @param string $method The method to call * @return string */ private function call($method) { return sprintf('%s::%s', __CLASS__, $method); } }