@@ -86,20 +86,23 @@ public function indexAction(Request $request, $_format)
86
86
$ cache = new ConfigCache ($ this ->exposedRoutesExtractor ->getCachePath ($ request ->getLocale ()), $ this ->debug );
87
87
88
88
if (!$ cache ->isFresh ()) {
89
- $ content = $ this ->serializer ->serialize (
90
- new RoutesResponse (
91
- $ this ->exposedRoutesExtractor ->getBaseUrl (),
92
- $ this ->exposedRoutesExtractor ->getRoutes (),
93
- $ this ->exposedRoutesExtractor ->getPrefix ($ request ->getLocale ()),
94
- $ this ->exposedRoutesExtractor ->getHost (),
95
- $ this ->exposedRoutesExtractor ->getScheme ()
96
- ),
97
- 'json '
98
- );
99
- $ cache ->write ($ content , $ this ->exposedRoutesExtractor ->getResources ());
89
+ $ exposedRoutes = $ this ->exposedRoutesExtractor ->getRoutes ();
90
+ $ serializedRoutes = $ this ->serializer ->serialize ($ exposedRoutes , 'json ' );
91
+ $ cache ->write ($ serializedRoutes , $ this ->exposedRoutesExtractor ->getResources ());
92
+ } else {
93
+ $ serializedRoutes = file_get_contents ((string ) $ cache );
94
+ $ exposedRoutes = json_decode ($ serializedRoutes , true );
100
95
}
101
96
102
- $ content = file_get_contents ((string ) $ cache );
97
+ $ routesResponse = new RoutesResponse (
98
+ $ this ->exposedRoutesExtractor ->getBaseUrl (),
99
+ $ exposedRoutes ,
100
+ $ this ->exposedRoutesExtractor ->getPrefix ($ request ->getLocale ()),
101
+ $ this ->exposedRoutesExtractor ->getHost (),
102
+ $ this ->exposedRoutesExtractor ->getScheme ()
103
+ );
104
+
105
+ $ content = $ this ->serializer ->serialize ($ routesResponse , 'json ' );
103
106
104
107
if (null !== $ callback = $ request ->query ->get ('callback ' )) {
105
108
$ validator = new \JsonpCallbackValidator ();
0 commit comments