Permalink
Browse files

Updated to be compatible with Symfony master

The route also accepts json as a valid format now for people wanting to
use a different way to initialize the JS router.
  • Loading branch information...
1 parent f78033d commit 1a02f6383581149eeb1405dee8d97b7592b97f98 @stof stof committed Dec 18, 2011
Showing with 4 additions and 5 deletions.
  1. +2 −2 Controller/Controller.php
  2. +1 −1 Resources/config/routing/routing.xml
  3. +1 −2 Resources/config/serializer.xml
@@ -57,14 +57,14 @@ public function __construct($serializer, ExposedRoutesExtractorInterface $expose
*/
public function indexAction(Request $request, $_format)
{
- $cache = new ConfigCache($this->cacheDir.'/fosJsRouting.'.$_format, $this->debug);
+ $cache = new ConfigCache($this->cacheDir.'/fosJsRouting.json', $this->debug);
@willdurand

willdurand Dec 19, 2011

Owner

What about removing the _format parameter and just keep js/json ? After all, it doesn't make sense to use something else ?

@stof

stof Dec 19, 2011

Owner

$_format can only be js or json. See the routing requirement. I only use the argument to set the content type. But we could even drop it and let the ResponseListener handle it

if (!$cache->isFresh()) {
$content = $this->serializer->serialize(
new RoutesResponse(
$this->exposedRoutesExtractor->getBaseUrl(),
$this->exposedRoutesExtractor->getRoutes()
),
- $_format
+ 'json'
);
$cache->write($content, $this->exposedRoutesExtractor->getResources());
}
@@ -6,6 +6,6 @@
<route id="fos_js_routing_js" pattern="/js/routing.{_format}">
<default key="_controller">fos_js_routing.controller:indexAction</default>
<default key="_format">js</default>
- <requirement key="_format">js</requirement>
+ <requirement key="_format">js|json</requirement>
</route>
</routes>
@@ -10,10 +10,9 @@
</argument>
<argument type="collection">
<argument key="json" type="service" id="fos_js_routing.encoder" />
- <argument key="js" type="service" id="fos_js_routing.encoder" />
</argument>
</service>
-
+
<service id="fos_js_routing.normalizer" class="Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer" public="false" />
<service id="fos_js_routing.encoder" class="Symfony\Component\Serializer\Encoder\JsonEncoder" public="false" />
</services>

0 comments on commit 1a02f63

Please sign in to comment.