diff --git a/src/Events/FeatureStarted.php b/src/Events/FeatureStarted.php new file mode 100644 index 0000000..4b77819 --- /dev/null +++ b/src/Events/FeatureStarted.php @@ -0,0 +1,27 @@ +name = $name; + $this->arguments = $arguments; + } +} diff --git a/src/Events/JobStarted.php b/src/Events/JobStarted.php new file mode 100644 index 0000000..604bced --- /dev/null +++ b/src/Events/JobStarted.php @@ -0,0 +1,27 @@ +name = $name; + $this->arguments = $arguments; + } +} diff --git a/src/Events/OperationStarted.php b/src/Events/OperationStarted.php new file mode 100644 index 0000000..f47b663 --- /dev/null +++ b/src/Events/OperationStarted.php @@ -0,0 +1,27 @@ +name = $name; + $this->arguments = $arguments; + } +} diff --git a/src/JobDispatcherTrait.php b/src/JobDispatcherTrait.php index 35092f9..1f0bbf2 100644 --- a/src/JobDispatcherTrait.php +++ b/src/JobDispatcherTrait.php @@ -2,6 +2,8 @@ namespace Lucid\Foundation; +use Lucid\Foundation\Events\JobStarted; +use Lucid\Foundation\Events\OperationStarted; use ReflectionClass; use Illuminate\Http\Request; use Illuminate\Support\Collection; @@ -31,6 +33,13 @@ public function run($job, $arguments = [], $extra = []) $job = $this->marshal($job, new Collection(), $arguments); } + if ($job instanceof Operation) { + event(new OperationStarted(get_class($job), $arguments)); + } + if ($job instanceof Job) { + event(new JobStarted(get_class($job), $arguments)); + } + $result = $this->dispatch($job, $arguments); } diff --git a/src/ServesFeaturesTrait.php b/src/ServesFeaturesTrait.php index a7d2ff9..7c6ec3c 100644 --- a/src/ServesFeaturesTrait.php +++ b/src/ServesFeaturesTrait.php @@ -4,6 +4,7 @@ use Illuminate\Support\Collection; use Illuminate\Foundation\Bus\DispatchesJobs; +use Lucid\Foundation\Events\FeatureStarted; trait ServesFeaturesTrait { @@ -20,6 +21,8 @@ trait ServesFeaturesTrait */ public function serve($feature, $arguments = []) { + event(new FeatureStarted($feature, $arguments)); + return $this->dispatch($this->marshal($feature, new Collection(), $arguments)); } }