-
Notifications
You must be signed in to change notification settings - Fork 708
/
ConfigurationCheckPass.php
42 lines (36 loc) · 1.62 KB
/
ConfigurationCheckPass.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/*
* This file is part of the FOSRestBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FOS\RestBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Checks if the SensioFrameworkExtraBundle views annotations are disabled when using the View Response listener.
*
* @author Eriksen Costa <eriksencosta@gmail.com>
*
* @internal
*/
final class ConfigurationCheckPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if ($container->has('fos_rest.converter.request_body') && !$container->has('sensio_framework_extra.converter.listener')) {
throw new \RuntimeException('You need to enable the parameter converter listeners in SensioFrameworkExtraBundle when using the FOSRestBundle RequestBodyParamConverter');
}
if ($container->has('fos_rest.view_response_listener') && isset($container->getParameter('kernel.bundles')['SensioFrameworkExtraBundle'])) {
if (!$container->has('sensio_framework_extra.view.listener')) {
throw new \RuntimeException('You must enable the SensioFrameworkExtraBundle view annotations to use the ViewResponseListener.');
}
}
if (!$container->has((string) $container->getAlias('fos_rest.templating'))) {
$container->removeAlias('fos_rest.templating');
}
}
}