1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Zenstruck\ScheduleBundle\Schedule\Extension; |
4
|
|
|
|
5
|
|
|
use Zenstruck\ScheduleBundle\Schedule\Exception\SkipSchedule; |
6
|
|
|
use Zenstruck\ScheduleBundle\Schedule\Exception\SkipTask; |
7
|
|
|
use Zenstruck\ScheduleBundle\Schedule\ScheduleRunContext; |
8
|
|
|
use Zenstruck\ScheduleBundle\Schedule\Task\TaskRunContext; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @author Kevin Bond <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
abstract class ExtensionHandler |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Skip entire schedule if \Zenstruck\ScheduleBundle\Schedule\Exception\SkipSchedule |
17
|
|
|
* exception is thrown. |
18
|
|
|
* |
19
|
|
|
* @throws SkipSchedule |
20
|
|
|
*/ |
21
|
5 |
|
public function filterSchedule(ScheduleRunContext $context, object $extension): void |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
// noop |
24
|
5 |
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Executes before the schedule runs. |
28
|
|
|
*/ |
29
|
5 |
|
public function beforeSchedule(ScheduleRunContext $context, object $extension): void |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
// noop |
32
|
5 |
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Executes after the schedule runs. |
36
|
|
|
*/ |
37
|
5 |
|
public function afterSchedule(ScheduleRunContext $context, object $extension): void |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
// noop |
40
|
5 |
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Executes if the schedule ran with no failures. |
44
|
|
|
*/ |
45
|
2 |
|
public function onScheduleSuccess(ScheduleRunContext $context, object $extension): void |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
// noop |
48
|
2 |
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Executes if the schedule ran with failures. |
52
|
|
|
*/ |
53
|
|
|
public function onScheduleFailure(ScheduleRunContext $context, object $extension): void |
|
|
|
|
54
|
|
|
{ |
55
|
|
|
// noop |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Skip task if \Zenstruck\ScheduleBundle\Schedule\Exception\SkipTask exception |
60
|
|
|
* is thrown. |
61
|
|
|
* |
62
|
|
|
* @throws SkipTask |
63
|
|
|
*/ |
64
|
10 |
|
public function filterTask(TaskRunContext $context, object $extension): void |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
// noop |
67
|
10 |
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Executes before the task runs (not if skipped). |
71
|
|
|
*/ |
72
|
16 |
|
public function beforeTask(TaskRunContext $context, object $extension): void |
|
|
|
|
73
|
|
|
{ |
74
|
|
|
// noop |
75
|
16 |
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Executes after the task runs (not if skipped). |
79
|
|
|
*/ |
80
|
13 |
|
public function afterTask(TaskRunContext $context, object $extension): void |
|
|
|
|
81
|
|
|
{ |
82
|
|
|
// noop |
83
|
13 |
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Executes if the task ran successfully (not if skipped). |
87
|
|
|
*/ |
88
|
4 |
|
public function onTaskSuccess(TaskRunContext $context, object $extension): void |
|
|
|
|
89
|
|
|
{ |
90
|
|
|
// noop |
91
|
4 |
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Executes if the task failed (not if skipped). |
95
|
|
|
*/ |
96
|
8 |
|
public function onTaskFailure(TaskRunContext $context, object $extension): void |
|
|
|
|
97
|
|
|
{ |
98
|
|
|
// noop |
99
|
8 |
|
} |
100
|
|
|
|
101
|
|
|
abstract public function supports(object $extension): bool; |
102
|
|
|
} |
103
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.