Passed
Pull Request — main (#140)
by Daniel
07:55 queued 02:24
created

SerializerCompilerPass   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 16
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 14 2
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\DependencyInjection\CompilerPass;
15
16
use Silverback\ApiComponentsBundle\Serializer\MappingLoader\CwaResourceLoader;
17
use Silverback\ApiComponentsBundle\Serializer\MappingLoader\PublishableLoader;
18
use Silverback\ApiComponentsBundle\Serializer\MappingLoader\TimestampedLoader;
19
use Silverback\ApiComponentsBundle\Serializer\MappingLoader\UploadableLoader;
20
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
21
use Symfony\Component\DependencyInjection\ContainerBuilder;
22
use Symfony\Component\DependencyInjection\Reference;
23
24
/**
25
 * @author Vincent Chalamon <[email protected]>
26
 */
27
class SerializerCompilerPass implements CompilerPassInterface
28
{
29
    public function process(ContainerBuilder $container)
30
    {
31
        $definitions = ['serializer.mapping.chain_loader', 'serializer.mapping.cache_warmer'];
32
        foreach ($definitions as $definitonId) {
33
            $definition = $container->getDefinition($definitonId);
34
            $definition->replaceArgument(
35
                0,
36
                array_merge(
37
                    $definition->getArgument(0),
38
                    [
39
                        new Reference(PublishableLoader::class),
40
                        new Reference(TimestampedLoader::class),
41
                        new Reference(CwaResourceLoader::class),
42
                        new Reference(UploadableLoader::class),
43
                    ]
44
                )
45
            );
46
        }
47
    }
48
}
49