|
4 | 4 |
|
5 | 5 | namespace Macpaw\SchemaContextBundle\DependencyInjection; |
6 | 6 |
|
7 | | -use Macpaw\SchemaContextBundle\Messenger\Transport\DoctrineTransportFactoryDecorator; |
8 | | -use Macpaw\SchemaContextBundle\Service\BaggageSchemaResolver; |
9 | 7 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
10 | 8 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
11 | | -use Symfony\Component\DependencyInjection\Definition; |
12 | | -use Symfony\Component\DependencyInjection\Reference; |
13 | 9 |
|
14 | 10 | final class SchemaContextCompilerPass implements CompilerPassInterface |
15 | 11 | { |
16 | | - public const TARGET_ID = 'messenger.transport.doctrine.factory'; |
17 | | - public const DECORATOR_ID = 'messenger.doctrine_transport_factory.decorator'; |
18 | | - |
19 | 12 | public function process(ContainerBuilder $container): void |
20 | 13 | { |
21 | | - if ($container->hasDefinition(self::TARGET_ID) === false) { |
22 | | - return; |
23 | | - } |
24 | | - |
25 | | - $def = new Definition(DoctrineTransportFactoryDecorator::class); |
26 | | - $def->setAutowired(true); // avoid pulling the chain or adding tags |
27 | | - $def->setAutoconfigured(true); |
28 | | - $def->setPublic(false); |
29 | | - |
30 | | - // Decorate the *target* id; explicit inner id is "<decorator>.inner" |
31 | | - $def->setDecoratedService(self::TARGET_ID, self::DECORATOR_ID . '.inner'); |
32 | | - |
33 | | - // Inject the inner/original factory + your resolver |
34 | | - $def->setArgument('$decoratedFactory', new Reference(self::DECORATOR_ID . '.inner')); |
35 | | - $def->setArgument('$baggageSchemaResolver', new Reference(BaggageSchemaResolver::class)); |
36 | | - |
37 | | - $container->setDefinition(self::DECORATOR_ID, $def); |
38 | 14 | } |
39 | 15 | } |
0 commit comments