Skip to content

Instantly share code, notes, and snippets.

@Mulkave
Created June 8, 2016 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mulkave/bbc87754a807a77fffa40b20d7e742d3 to your computer and use it in GitHub Desktop.
Save Mulkave/bbc87754a807a77fffa40b20d7e742d3 to your computer and use it in GitHub Desktop.
<?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