SilverbackApiComponentsBundle   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 21
ccs 0
cts 13
cp 0
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 19 3
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
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
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentsBundle;
15
16
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
17
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\ApiPlatformCompilerPass;
18
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\DoctrineOrmCompilerPass;
19
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\FlysystemCompilerPass;
20
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\ImagineCompilerPass;
21
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\SerializerCompilerPass;
22
use Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass\ValidatorCompilerPass;
23
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
24
use Symfony\Component\DependencyInjection\ContainerBuilder;
25
use Symfony\Component\HttpKernel\Bundle\Bundle;
26
27
/**
28
 * @author Daniel West <[email protected]>
29
 */
30
class SilverbackApiComponentsBundle extends Bundle
31
{
32
    public function build(ContainerBuilder $container): void
33
    {
34
        parent::build($container);
35
36
        // run before the doctrine listeners are parsed - we may be removing it
37
        $container->addCompilerPass(new ApiPlatformCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1);
38
        $container->addCompilerPass(new SerializerCompilerPass());
39
        $container->addCompilerPass(new ValidatorCompilerPass());
40
        $container->addCompilerPass(new FlysystemCompilerPass());
41
42
        if (class_exists(DoctrineOrmMappingsPass::class)) {
43
            $container->addCompilerPass(new DoctrineOrmCompilerPass());
44
        }
45
46
        $bundles = $container->getParameter('kernel.bundles');
47
        $imagineEnabled = isset($bundles['LiipImagineBundle']);
48
        $container->setParameter('api_components.imagine_enabled', $imagineEnabled);
49
        if ($imagineEnabled) {
50
            $container->addCompilerPass(new ImagineCompilerPass());
51
        }
52
    }
53
}
54