Skip to content

Commit

Permalink
Add dispatch_sync helper (#36835)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints authored Apr 1, 2021
1 parent 0ac0520 commit 97fe4a1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Bus/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Contracts/Bus/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Foundation/Bus/Dispatchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
16 changes: 16 additions & 0 deletions src/Illuminate/Foundation/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Testing/Fakes/BusFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 97fe4a1

Please sign in to comment.