|
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
|
|
|
|