Skip to content

Commit 941d4c8

Browse files
authored
Merge pull request #1263 from h0raz/symfony_config_allow_null
Symfony config allow null
2 parents 6548f9c + 6686518 commit 941d4c8

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ public function buildConnectionFactory(ContainerBuilder $container, array $confi
132132
$container->register($factoryFactoryId, $config['factory_class'] ?? ConnectionFactoryFactory::class);
133133

134134
$factoryFactoryService = new Reference(
135-
array_key_exists('factory_service', $config) ? $config['factory_service'] : $factoryFactoryId
135+
$config['factory_service'] ?? $factoryFactoryId
136136
);
137137

138138
unset($config['factory_service'], $config['factory_class']);
139139

140-
if (array_key_exists('connection_factory_class', $config)) {
141-
$connectionFactoryClass = $config['connection_factory_class'];
142-
unset($config['connection_factory_class']);
140+
$connectionFactoryClass = $config['connection_factory_class'] ?? null;
141+
unset($config['connection_factory_class']);
143142

143+
if (isset($connectionFactoryClass)) {
144144
$container->register($factoryId, $connectionFactoryClass)
145145
->addArgument($config)
146146
;

Diff for: pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,14 @@ public function testShouldBuildConnectionFactoryFromDSN()
259259

260260
$transport = new TransportFactory('default');
261261

262-
$transport->buildConnectionFactory($container, ['dsn' => 'foo://bar/baz']);
262+
$config = [
263+
'dsn' => 'foo://bar/baz',
264+
'connection_factory_class' => null,
265+
'factory_service' => null,
266+
'factory_class' => null,
267+
];
268+
269+
$transport->buildConnectionFactory($container, $config);
263270

264271
$this->assertTrue($container->hasDefinition('enqueue.transport.default.connection_factory'));
265272

0 commit comments

Comments
 (0)