-
-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathException.php
More file actions
77 lines (65 loc) · 2.1 KB
/
Exception.php
File metadata and controls
77 lines (65 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
declare(strict_types=1);
namespace Workflow;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Workflow\Exceptions\TransitionNotFound;
use Workflow\Middleware\WithoutOverlappingMiddleware;
use Workflow\Models\StoredWorkflow;
final class Exception implements ShouldBeEncrypted, ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
public ?string $key = null;
public $tries = PHP_INT_MAX;
public $maxExceptions = PHP_INT_MAX;
public $timeout = 0;
public function __construct(
public int $index,
public string $now,
public StoredWorkflow $storedWorkflow,
public $exception,
$connection = null,
$queue = null
) {
$connection = $connection ?? $this->storedWorkflow->effectiveConnection() ?? config('queue.default');
$queue = $queue ?? $this->storedWorkflow->effectiveQueue() ?? config(
'queue.connections.' . $connection . '.queue',
'default'
);
$this->onConnection($connection);
$this->onQueue($queue);
}
public function handle()
{
$workflow = $this->storedWorkflow->toWorkflow();
try {
if ($this->storedWorkflow->hasLogByIndex($this->index)) {
$workflow->resume();
} elseif (! $this->storedWorkflow->logs()->where('class', self::class)->exists()) {
$workflow->next($this->index, $this->now, self::class, $this->exception);
}
} catch (TransitionNotFound) {
if ($workflow->running()) {
$this->release();
}
}
}
public function middleware()
{
return [
new WithoutOverlappingMiddleware(
$this->storedWorkflow->id,
WithoutOverlappingMiddleware::ACTIVITY,
0,
15
),
];
}
}