From 5ccd5de305fd3330c6f6eb637809e2b18f725449 Mon Sep 17 00:00:00 2001 From: Oliver Stark Date: Tue, 18 Jan 2022 12:17:57 +0100 Subject: [PATCH] Support cli queue runner too --- CHANGELOG.md | 1 + src/Handlers/QueueServiceHandler.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c62d070..c9b8903 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes will be documented in this file. - Fixed phpstan (1.4) level 6 - After install example.config.php is copied to config/relax.php +- Support cli queue runner too, including AsyncQueue ## 1.0.0 - 2022-01-18 diff --git a/src/Handlers/QueueServiceHandler.php b/src/Handlers/QueueServiceHandler.php index 9acc11f..1a965bb 100644 --- a/src/Handlers/QueueServiceHandler.php +++ b/src/Handlers/QueueServiceHandler.php @@ -31,9 +31,17 @@ public function __invoke(): void return; } - // Overwrite 'queue' key in service locator + // Initialize HashedJobQueue $serializer = Craft::$app->getQueue()->serializer; $hasher = new DefaultHasher($serializer); - Craft::$app->set('queue', new HashedJobQueue($hasher)); + $queue = new HashedJobQueue($hasher); + + // Overwrite 'queue' key in service locator + Craft::$app->set('queue', $queue); + + // Overwrite 'queue' property of queue\Command + if (isset(Craft::$app->controllerMap['queue']['queue'])) { + Craft::$app->controllerMap['queue']['queue'] = $queue; + } } }