Skip to content

Commit d8d9418

Browse files
committed
automatically set sensio_framework_extra { view: { annotations: false } } if view_response_listener is enabled
1 parent 559f7d6 commit d8d9418

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

DependencyInjection/FOSRestExtension.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,32 @@
1212
namespace FOS\RestBundle\DependencyInjection;
1313

1414
use Symfony\Component\Config\FileLocator;
15+
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
1516
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
1718
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1819
use Symfony\Component\DependencyInjection\DefinitionDecorator;
1920
use Symfony\Component\DependencyInjection\Reference;
2021
use FOS\RestBundle\Util\Codes;
2122

22-
class FOSRestExtension extends Extension
23+
class FOSRestExtension extends Extension implements PrependExtensionInterface
2324
{
25+
/**
26+
* Default sensio_framework_extra { view: { annotations: false } }
27+
*
28+
* {@inheritDoc}
29+
*/
30+
public function prepend(ContainerBuilder $container)
31+
{
32+
$configs = $container->getExtensionConfig($this->getAlias());
33+
$parameterBag = $container->getParameterBag();
34+
$configs = $parameterBag->resolveValue($configs);
35+
$config = $this->processConfiguration(new Configuration(), $configs);
36+
37+
if (!empty($config['view']['view_response_listener'])) {
38+
$container->prependExtensionConfig('sensio_framework_extra', array('view' => array('annotations' => false)));
39+
}
40+
}
2441
/**
2542
* Loads the services based on your application configuration.
2643
*

0 commit comments

Comments
 (0)