Completed
Pull Request — master (#1382)
by Guilh
10:54 queued 07:09
created

ConfigurationCheckPass   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
c 2
b 1
f 0
lcom 0
cbo 1
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 12 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