1
0
Fork 0
mirror of https://github.com/archtechx/jobpipeline.git synced 2025-12-12 18:24:05 +00:00

feat: allow custom method names

This commit is contained in:
Julian Hundeloh 2024-05-24 19:14:22 +02:00 committed by GitHub
parent 8b793e0cf2
commit 524f05e749
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -65,12 +65,12 @@ class JobPipeline implements ShouldQueue
public function handle(): void public function handle(): void
{ {
foreach ($this->jobs as $job) { foreach ($this->jobs as $job) {
if (is_string($job)) { if (class_exists($job)) {
$job = [new $job(...$this->passable), 'handle']; $job = [new $job(...$this->passable), 'handle'];
} }
try { try {
$result = app()->call($job); $result = app()->call($job, $this->passable);
} catch (Throwable $exception) { } catch (Throwable $exception) {
if (method_exists(get_class($job[0]), 'failed')) { if (method_exists(get_class($job[0]), 'failed')) {
call_user_func_array([$job[0], 'failed'], [$exception]); call_user_func_array([$job[0], 'failed'], [$exception]);