Created
June 8, 2016 21:02
-
-
Save Mulkave/bbc87754a807a77fffa40b20d7e742d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Directory\Foundation; | |
use Illuminate\Http\Request; | |
use Illuminate\Contracts\Bus\SelfHandling; | |
use Illuminate\Foundation\Bus\DispatchesJobs; | |
abstract class Feature implements SelfHandling | |
{ | |
use DispatchesJobs; | |
public function run($job, $arguments) | |
{ | |
if ($arguments instanceof Request) { | |
$result = $this->dispatchFrom($job, $arguments, $extra); | |
} else { | |
$result = $this->dispatchFromArray($job, $arguments); | |
} | |
return $result; | |
} | |
public function runInQueue($job, $arguments, Queue $queue = null) | |
{ | |
if (!$queue) { | |
$queue = DefaultQueue::class; | |
} | |
$reflection = new ReflectionClass($job); | |
$jobInstance = $reflection->newInstanceArgs($arguments); | |
$jobInstance->onQueue((string) $queue); | |
$this->dispatch($jobInstance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment