Permalink
Browse files

made it easier to customize the router, templating and serializer ser…

…vices
  • Loading branch information...
lsmith77 committed Sep 7, 2011
1 parent 8f53bb4 commit 91bc7dc8490af0ec2f8535d23b2cfbaec1864384
@@ -74,6 +74,9 @@ public function getConfigTreeBuilder()
->arrayNode('service')
->addDefaultsIfNotSet()
->children()
+ ->scalarNode('router')->defaultValue('router')->end()
+ ->scalarNode('templating')->defaultValue('templating')->end()
+ ->scalarNode('serializer')->defaultValue('serializer')->end()
->scalarNode('view_handler')->defaultValue('fos_rest.view_handler.default')->end()
->end()
->end()
@@ -49,7 +49,9 @@ public function load(array $configs, ContainerBuilder $container)
}
}
- $container->setAlias($this->getAlias().'.view_handler', $config['service']['view_handler']);
+ foreach ($config['service'] as $key => $service) {
+ $container->setAlias($this->getAlias().'.'.$key, $config['service'][$key]);

This comment has been minimized.

Show comment Hide comment
@schmittjoh

schmittjoh Sep 7, 2011

Contributor

You should probably create private aliases here.

@schmittjoh

schmittjoh Sep 7, 2011

Contributor

You should probably create private aliases here.

This comment has been minimized.

Show comment Hide comment
@lsmith77

lsmith77 Sep 7, 2011

Owner

this will not work since they are not injected into the ViewHandler but fetched from the container as they are all optional.

@lsmith77

lsmith77 Sep 7, 2011

Owner

this will not work since they are not injected into the ViewHandler but fetched from the container as they are all optional.

+ }
$container->setParameter($this->getAlias().'.formats', $formats);
$container->setParameter($this->getAlias().'.default_engine', $config['view']['default_engine']);
View
@@ -774,5 +774,8 @@ fos_rest:
fallback_format: html
prefer_extension: false
service:
+ router: router
+ templating: templating
+ serializer: serializer
view_handler: fos_rest.view_handler.default
```
@@ -146,7 +146,7 @@ public function testCreateResponseWithoutLocation($format, $expected, $createVie
$container
->expects($this->once())
->method('get')
- ->with('templating')
+ ->with('fos_rest.templating')
->will($this->returnValue($templating));
} else {
$serializer = $this->getMock('\stdClass', array('serialize'));
@@ -158,7 +158,7 @@ public function testCreateResponseWithoutLocation($format, $expected, $createVie
$container
->expects($this->once())
->method('get')
- ->with('serializer')
+ ->with('fos_rest.serializer')
->will($this->returnValue($serializer));
}
View
@@ -148,7 +148,7 @@ public function isFormatTemplating($format)
*/
protected function getRouter()
{
- return $this->container->get('router');
+ return $this->container->get('fos_rest.router');
}
/**
@@ -158,7 +158,7 @@ protected function getRouter()
*/
protected function getSerializer()
{
- return $this->container->get('serializer');
+ return $this->container->get('fos_rest.serializer');
}
/**
@@ -168,7 +168,7 @@ protected function getSerializer()
*/
protected function getTemplating()
{
- return $this->container->get('templating');
+ return $this->container->get('fos_rest.templating');
}
/**

0 comments on commit 91bc7dc

Please sign in to comment.