/**
  * indexAction action.
  */
 public function indexAction(Request $request, $_format)
 {
     $session = $request->getSession();
     if ($request->hasPreviousSession() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
         // keep current flashes for one more request if using AutoExpireFlashBag
         $session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
     }
     $cache = new ConfigCache($this->exposedRoutesExtractor->getCachePath($request->getLocale()), $this->debug);
     if (!$cache->isFresh()) {
         $exposedRoutes = $this->exposedRoutesExtractor->getRoutes();
         $serializedRoutes = $this->serializer->serialize($exposedRoutes, 'json');
         $cache->write($serializedRoutes, $this->exposedRoutesExtractor->getResources());
     } else {
         $serializedRoutes = file_get_contents((string) $cache);
         $exposedRoutes = $this->serializer->deserialize($serializedRoutes, 'Symfony\\Component\\Routing\\RouteCollection', 'json');
     }
     $routesResponse = new RoutesResponse($this->exposedRoutesExtractor->getBaseUrl(), $exposedRoutes, $this->exposedRoutesExtractor->getPrefix($request->getLocale()), $this->exposedRoutesExtractor->getHost(), $this->exposedRoutesExtractor->getScheme(), $request->getLocale());
     $content = $this->serializer->serialize($routesResponse, 'json');
     if (null !== ($callback = $request->query->get('callback'))) {
         $validator = new \JsonpCallbackValidator();
         if (!$validator->validate($callback)) {
             throw new HttpException(400, 'Invalid JSONP callback value');
         }
         $content = $callback . '(' . $content . ');';
     }
     $response = new Response($content, 200, array('Content-Type' => $request->getMimeType($_format)));
     $this->cacheControlConfig->apply($response);
     return $response;
 }
 /**
  * Performs the routes dump.
  *
  * @param InputInterface  $input  The command input
  * @param OutputInterface $output The command output
  */
 private function doDump(InputInterface $input, OutputInterface $output)
 {
     if (!is_dir($dir = dirname($this->targetPath))) {
         $output->writeln('<info>[dir+]</info>  ' . $dir);
         if (false === @mkdir($dir, 0777, true)) {
             throw new \RuntimeException('Unable to create directory ' . $dir);
         }
     }
     $output->writeln('<info>[file+]</info> ' . $this->targetPath);
     $baseUrl = $this->getContainer()->hasParameter('fos_js_routing.request_context_base_url') ? $this->getContainer()->getParameter('fos_js_routing.request_context_base_url') : $this->extractor->getBaseUrl();
     $content = $this->serializer->serialize(new RoutesResponse($baseUrl, $this->extractor->getRoutes($input->getOption('sets')), $input->getOption('locale'), $this->extractor->getHost(), $this->extractor->getScheme()), 'json');
     $content = sprintf("%s(%s);", $input->getOption('callback'), $content);
     if (false === @file_put_contents($this->targetPath, $content)) {
         throw new \RuntimeException('Unable to write file ' . $this->targetPath);
     }
 }