Skip to content

Commit

Permalink
add dispatchEventually
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid committed Jan 30, 2020
1 parent fc844ce commit 2edd560
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Illuminate/Bus/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@ protected function pushCommandToQueue($queue, $command)
return $queue->push($command);
}

/**
* Dispatch a command to its appropriate handler after the current process.
*
* @param mixed $command
* @param mixed $handler
* @return void
*/
public function dispatchEventually($command, $handler = null)
{
$this->container->terminating(function () use ($command, $handler) {
$this->dispatchNow($command, $handler);
});
}

/**
* Set the pipes through which commands should be piped before dispatching.
*
Expand Down
14 changes: 14 additions & 0 deletions src/Illuminate/Foundation/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,20 @@ function dispatch_now($job, $handler = null)
}
}

if (! function_exists('dispatch_eventually')) {
/**
* Dispatch a command to its appropriate handler after the current process.
*
* @param mixed $job
* @param mixed $handler
* @return void
*/
function dispatch_eventually($job, $handler = null)
{
return app(Dispatcher::class)->dispatchEventually($job, $handler);
}
}

if (! function_exists('elixir')) {
/**
* Get the path to a versioned Elixir file.
Expand Down

0 comments on commit 2edd560

Please sign in to comment.