Skip to content

Commit ca37484

Browse files
committed
Use packages list to detect job launcher instead of ifs
1 parent 405da8e commit ca37484

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/batch-symfony-framework/src/DependencyInjection/YokaiBatchExtension.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ public function load(array $configs, ContainerBuilder $container): void
4747

4848
$this->configureStorage($container, $config['storage']);
4949

50-
$launcher = 'yokai_batch.job_launcher.simple';
51-
if ($this->installed('symfony-messenger')) {
52-
$launcher = 'yokai_batch.job_launcher.dispatch_message';
53-
} elseif ($this->installed('symfony-console')) {
54-
$launcher = 'yokai_batch.job_launcher.run_command';
55-
}
56-
$container->setAlias(JobLauncherInterface::class, $launcher);
50+
$launchers = [
51+
'yokai_batch.job_launcher.dispatch_message' => $this->installed('symfony-messenger'),
52+
'yokai_batch.job_launcher.run_command' => $this->installed('symfony-console'),
53+
];
54+
$container->setAlias(
55+
JobLauncherInterface::class,
56+
\array_keys(\array_filter($launchers))[0] ?? 'yokai_batch.job_launcher.simple'
57+
);
5758
}
5859

5960
private function installed(string $package): bool

0 commit comments

Comments
 (0)