Completed
Push — master ( d8eda0...528d5a )
by Guilh
9s
created

ConfigurationCheckPass::process()   B

Complexity

Conditions 6
Paths 4

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 6

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 8.8571
cc 6
eloc 6
nc 4
nop 1
crap 6
1
<?php
2
3
/*
4
 * This file is part of the FOSRestBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\RestBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
17
/**
18
 * Checks if the SensioFrameworkExtraBundle views annotations are disabled when using the View Response listener.
19
 *
20
 * @author Eriksen Costa <[email protected]>
21
 *
22
 * @internal
23
 */
24
final class ConfigurationCheckPass implements CompilerPassInterface
25
{
26 10
    public function process(ContainerBuilder $container)
27
    {
28 10
        if ($container->has('fos_rest.converter.request_body') && !$container->has('sensio_framework_extra.converter.listener')) {
29 1
            throw new \RuntimeException('You need to enable the parameter converter listeners in SensioFrameworkExtraBundle when using the FOSRestBundle RequestBodyParamConverter');
30
        }
31
32 9
        if ($container->has('fos_rest.view_response_listener') && isset($container->getParameter('kernel.bundles')['SensioFrameworkExtraBundle'])) {
33 4
            if (!$container->has('sensio_framework_extra.view.listener')) {
34 1
                throw new \RuntimeException('You must enable the SensioFrameworkExtraBundle view annotations to use the ViewResponseListener.');
35
            }
36 3
        }
37 8
    }
38
}
39