From f234727cee64f0275e52a1ae5557043e2cc296c0 Mon Sep 17 00:00:00 2001 From: Nazar Salo Date: Thu, 26 Jul 2018 12:37:46 +0300 Subject: [PATCH] Improve runInQueue method: ability to parse args by key --- .gitignore | 1 + src/JobDispatcherTrait.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 57872d0..491f666 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /vendor/ +.idea/ diff --git a/src/JobDispatcherTrait.php b/src/JobDispatcherTrait.php index 35092f9..5348895 100644 --- a/src/JobDispatcherTrait.php +++ b/src/JobDispatcherTrait.php @@ -49,8 +49,12 @@ public function run($job, $arguments = [], $extra = []) public function runInQueue($job, array $arguments = [], $queue = 'default') { // instantiate and queue the job - $reflection = new ReflectionClass($job); - $jobInstance = $reflection->newInstanceArgs($arguments); + if ($arguments instanceof Request) { + $jobInstance = $this->marshal($job, $arguments, []); + } else { + $jobInstance = $this->marshal($job, new Collection(), $arguments); + } + $jobInstance->onQueue((string) $queue); return $this->dispatch($jobInstance);