Skip to content

Commit 1876a10

Browse files
committed
Add context services to locator
1 parent dec922e commit 1876a10

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Diff for: pkg/enqueue/Symfony/DependencyInjection/TransportFactory.php

+16-8
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ public function buildContext(ContainerBuilder $container, array $config): void
156156
->setFactory([new Reference($factoryId), 'createContext'])
157157
;
158158

159+
$this->fillLocator($container, 'context');
160+
159161
if ('default' === $this->name) {
160162
$container->setAlias(Context::class, $this->format('context'));
161163
}
@@ -187,14 +189,8 @@ public function buildQueueConsumer(ContainerBuilder $container, array $config):
187189

188190
$container->register($this->format('processor_registry'), ContainerProcessorRegistry::class);
189191

190-
$locatorId = 'enqueue.locator';
191-
if ($container->hasDefinition($locatorId)) {
192-
$locator = $container->getDefinition($locatorId);
193-
$locator->replaceArgument(0, array_replace($locator->getArgument(0), [
194-
$this->format('queue_consumer') => new Reference($this->format('queue_consumer')),
195-
$this->format('processor_registry') => new Reference($this->format('processor_registry')),
196-
]));
197-
}
192+
$this->fillLocator($container, 'queue_consumer');
193+
$this->fillLocator($container, 'processor_registry');
198194

199195
if ('default' === $this->name) {
200196
$container->setAlias(QueueConsumerInterface::class, $this->format('queue_consumer'));
@@ -226,4 +222,16 @@ private function assertServiceExists(ContainerBuilder $container, string $servic
226222
throw new \InvalidArgumentException(sprintf('The service "%s" does not exist.', $serviceId));
227223
}
228224
}
225+
226+
private function fillLocator(ContainerBuilder $container, string $serviceName): void
227+
{
228+
$locatorId = 'enqueue.locator';
229+
230+
if ($container->hasDefinition($locatorId)) {
231+
$locator = $container->getDefinition($locatorId);
232+
$locator->replaceArgument(0, array_replace($locator->getArgument(0), [
233+
$this->format($serviceName) => $this->reference($serviceName)),
234+
]));
235+
}
236+
}
229237
}

0 commit comments

Comments
 (0)