Skip to content

Commit

Permalink
* Removed parameter resolving
Browse files Browse the repository at this point in the history
* Store RouteCollection to avoid triggering twice
* Fixed namespaces
  • Loading branch information
borisguery authored and lsmith77 committed Jul 28, 2012
1 parent a4c68e1 commit 5c18127
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
5 changes: 1 addition & 4 deletions DependencyInjection/FOSRestExtension.php
Expand Up @@ -39,10 +39,7 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('util.xml');
$loader->load('request.xml');

$container->setParameter(
'fos_rest.cache_dir',
$container->getParameterBag()->resolveValue($config['cache_dir'])
);
$container->setParameter('fos_rest.cache_dir',$config['cache_dir']);

if (version_compare(FOSRestBundle::getSymfonyVersion(Kernel::VERSION), '2.1.0', '<')) {
$container->setParameter('fos_rest.routing.loader.controller.class', $container->getParameter('fos_rest.routing.loader_2_0.controller.class'));
Expand Down
2 changes: 1 addition & 1 deletion EventListener/AllowedMethodsListener.php
Expand Up @@ -13,7 +13,7 @@

use Symfony\Component\HttpKernel\Event\FilterResponseEvent;

use FOS\RestBundle\Util\AllowedMethodsLoaderInterface;
use FOS\RestBundle\EventListener\AllowedMethodsLoader\AllowedMethodsLoaderInterface;

/**
* Listener to append Allow-ed methods for a given route/resource
Expand Down
Expand Up @@ -73,7 +73,9 @@ public function warmUp($cacheDir)
{
$processedRoutes = array();

foreach ($this->router->getRouteCollection()->all() as $name => $route) {
$routeCollection = $this->router->getRouteCollection();

foreach ($routeCollection->all() as $name => $route) {

if (!isset($processedRoutes[$route->getPattern()])) {
$processedRoutes[$route->getPattern()] = array(
Expand Down Expand Up @@ -106,7 +108,7 @@ public function warmUp($cacheDir)

$this->cache->write(
sprintf('<?php return %s;', var_export($allowedMethods, true)),
$this->router->getRouteCollection()->getResources()
$routeCollection->getResources()
);
}
}
2 changes: 1 addition & 1 deletion Resources/config/allowed_methods_listener.xml
Expand Up @@ -7,7 +7,7 @@
<parameters>

<parameter key="fos_rest.allowed_methods_listener.class">FOS\RestBundle\EventListener\AllowedMethodsListener</parameter>
<parameter key="fos_rest.allowed_methods_loader.class">FOS\RestBundle\Util\AllowedMethodsRouterLoader</parameter>
<parameter key="fos_rest.allowed_methods_loader.class">FOS\RestBundle\EventListener\AllowedMethodsLoader\AllowedMethodsRouterLoader</parameter>

</parameters>

Expand Down

0 comments on commit 5c18127

Please sign in to comment.