From 97fe4a1a7cb8dd8982a2c8af98154dd030fe6c95 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Thu, 1 Apr 2021 15:09:31 +0200 Subject: [PATCH] Add dispatch_sync helper (#36835) --- src/Illuminate/Bus/Dispatcher.php | 2 +- src/Illuminate/Contracts/Bus/Dispatcher.php | 2 +- src/Illuminate/Foundation/Bus/Dispatchable.php | 2 +- src/Illuminate/Foundation/helpers.php | 16 ++++++++++++++++ src/Illuminate/Support/Testing/Fakes/BusFake.php | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Illuminate/Bus/Dispatcher.php b/src/Illuminate/Bus/Dispatcher.php index b33747b079d1..bab46f5e5de5 100644 --- a/src/Illuminate/Bus/Dispatcher.php +++ b/src/Illuminate/Bus/Dispatcher.php @@ -81,7 +81,7 @@ public function dispatch($command) /** * Dispatch a command to its appropriate handler in the current process. * - * Queuable jobs will be dispatched to the "sync" queue. + * Queueable jobs will be dispatched to the "sync" queue. * * @param mixed $command * @param mixed $handler diff --git a/src/Illuminate/Contracts/Bus/Dispatcher.php b/src/Illuminate/Contracts/Bus/Dispatcher.php index 1e1a714ba6db..5cbbd92954f6 100644 --- a/src/Illuminate/Contracts/Bus/Dispatcher.php +++ b/src/Illuminate/Contracts/Bus/Dispatcher.php @@ -15,7 +15,7 @@ public function dispatch($command); /** * Dispatch a command to its appropriate handler in the current process. * - * Queuable jobs will be dispatched to the "sync" queue. + * Queueable jobs will be dispatched to the "sync" queue. * * @param mixed $command * @param mixed $handler diff --git a/src/Illuminate/Foundation/Bus/Dispatchable.php b/src/Illuminate/Foundation/Bus/Dispatchable.php index 1a0e99dc8833..b6dfe02b121c 100644 --- a/src/Illuminate/Foundation/Bus/Dispatchable.php +++ b/src/Illuminate/Foundation/Bus/Dispatchable.php @@ -48,7 +48,7 @@ public static function dispatchUnless($boolean, ...$arguments) /** * Dispatch a command to its appropriate handler in the current process. * - * Queuable jobs will be dispatched to the "sync" queue. + * Queueable jobs will be dispatched to the "sync" queue. * * @return mixed */ diff --git a/src/Illuminate/Foundation/helpers.php b/src/Illuminate/Foundation/helpers.php index 3842915bf721..148beee35b38 100644 --- a/src/Illuminate/Foundation/helpers.php +++ b/src/Illuminate/Foundation/helpers.php @@ -390,6 +390,22 @@ function dispatch($job) } } +if (! function_exists('dispatch_sync')) { + /** + * Dispatch a command to its appropriate handler in the current process. + * + * Queueable jobs will be dispatched to the "sync" queue. + * + * @param mixed $job + * @param mixed $handler + * @return mixed + */ + function dispatch_sync($job, $handler = null) + { + return app(Dispatcher::class)->dispatchSync($job, $handler); + } +} + if (! function_exists('dispatch_now')) { /** * Dispatch a command to its appropriate handler in the current process. diff --git a/src/Illuminate/Support/Testing/Fakes/BusFake.php b/src/Illuminate/Support/Testing/Fakes/BusFake.php index 82f3dda5d129..106b5b1a74b9 100644 --- a/src/Illuminate/Support/Testing/Fakes/BusFake.php +++ b/src/Illuminate/Support/Testing/Fakes/BusFake.php @@ -435,7 +435,7 @@ public function dispatch($command) /** * Dispatch a command to its appropriate handler in the current process. * - * Queuable jobs will be dispatched to the "sync" queue. + * Queueable jobs will be dispatched to the "sync" queue. * * @param mixed $command * @param mixed $handler