Permalink
Browse files

allow per filter set configuration of the controller action

  • Loading branch information...
1 parent 736052d commit 03e49d67731c68ab7f9d4cb2a4e1b87d3a1ef332 @lsmith77 lsmith77 committed Nov 27, 2011
Showing with 10 additions and 3 deletions.
  1. +2 −1 DependencyInjection/Configuration.php
  2. +2 −0 README.md
  3. +6 −2 Routing/ImagineLoader.php
@@ -45,8 +45,9 @@ public function getConfigTreeBuilder()
->scalarNode('path')->end()
->scalarNode('quality')->defaultValue(100)->end()
->scalarNode('format')->defaultNull()->end()
- ->scalarNode('data_loader')->defaultNull()->end()
->scalarNode('cache')->defaultNull()->end()
+ ->scalarNode('data_loader')->defaultNull()->end()
+ ->scalarNode('controller_action')->defaultNull()->end()
->arrayNode('filters')
->useAttributeAsKey('name')
->prototype('array')
View
@@ -215,7 +215,9 @@ Each filter set that you specify has the following options:
and options that should be passed to the specific filter type
- `path` - used in place of the filter name to determine the path in combination with the global `cache_prefix`
- `quality` - override the default quality of 100 for the generated images
+ - `cache` - override the default cache setting
- `data_loader` - override the default data loader
+ - `controller_action` - override the default controller action
- `format` - hardcodes the output format (aka the requested format is ignored)
## Built-in Filters
@@ -28,7 +28,6 @@ public function supports($resource, $type = null)
public function load($resource, $type = null)
{
$requirements = array('_method' => 'GET', 'filter' => '[A-z0-9_\-]*', 'path' => '.+');
- $defaults = array('_controller' => $this->controllerAction);
$routes = new RouteCollection();
if (count($this->filters) > 0) {
@@ -42,9 +41,14 @@ public function load($resource, $type = null)
$pattern .= '/'.$filter;
}
+ $defaults = array(
+ '_controller' => empty($config['controller_action']) ? $this->controllerAction : $config['controller_action'],
+ 'filter' => $filter,
+ );
+
$routes->add('_imagine_'.$filter, new Route(
$pattern.'/{path}',
- array_merge( $defaults, array('filter' => $filter)),
+ $defaults,
$requirements
));
}

0 comments on commit 03e49d6

Please sign in to comment.