Passed
Push — main ( 964870...8374cd )
by Daniel
08:40 queued 03:10
created

SilverbackApiComponentsBundle::build()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 12
nc 4
nop 1
dl 0
loc 18
ccs 0
cts 13
cp 0
crap 12
rs 9.8666
c 0
b 0
f 0
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\ContainerBuilder;
24
use Symfony\Component\HttpKernel\Bundle\Bundle;
25
26
/**
27
 * @author Daniel West <[email protected]>
28
 */
29
class SilverbackApiComponentsBundle extends Bundle
30
{
31
    public function build(ContainerBuilder $container): void
32
    {
33
        parent::build($container);
34
35
        $container->addCompilerPass(new ApiPlatformCompilerPass());
36
        $container->addCompilerPass(new SerializerCompilerPass());
37
        $container->addCompilerPass(new ValidatorCompilerPass());
38
        $container->addCompilerPass(new FlysystemCompilerPass());
39
40
        if (class_exists(DoctrineOrmMappingsPass::class)) {
41
            $container->addCompilerPass(new DoctrineOrmCompilerPass());
42
        }
43
44
        $bundles = $container->getParameter('kernel.bundles');
45
        $imagineEnabled = isset($bundles['LiipImagineBundle']);
46
        $container->setParameter('api_components.imagine_enabled', $imagineEnabled);
47
        if ($imagineEnabled) {
48
            $container->addCompilerPass(new ImagineCompilerPass());
49
        }
50
    }
51
}
52