@@ -14,22 +14,35 @@ abstract class Operation
14
14
*
15
15
* If true, then it will be executed once.
16
16
* If false, then the operation will run every time the `operations` command is invoked.
17
+ *
18
+ * @deprecated Will be removed in 7.x version. Use `shouldOnce` method instead.
17
19
*/
18
20
protected bool $ once = true ;
19
21
20
22
/**
21
23
* Determines which environment to run on.
24
+ *
25
+ * @deprecated Will be removed in 7.x version. Use `withinEnvironment` method instead.
22
26
*/
23
27
protected array |string |null $ environment = null ;
24
28
25
29
/**
26
30
* Determines in which environment it should not run.
31
+ *
32
+ * @deprecated Will be removed in 7.x version. Use `exceptEnvironment` method instead.
27
33
*/
28
34
protected array |string |null $ exceptEnvironment = null ;
29
35
30
- /** Defines a possible "pre-launch" of the operation. */
36
+ /**
37
+ * Defines a possible "pre-launch" of the operation.
38
+ *
39
+ * @deprecated Will be removed in 7.x version. Use `hasBefore` method instead.
40
+ */
31
41
protected bool $ before = true ;
32
42
43
+ /**
44
+ * @deprecated
45
+ */
33
46
public function getConnection (): ?string
34
47
{
35
48
return config ('deploy-operations.connection ' );
@@ -40,22 +53,47 @@ public function getConnection(): ?string
40
53
*
41
54
* If true, then it will be executed once.
42
55
* If false, then the operation will run every time the `operations` command is invoked.
56
+ *
57
+ * @deprecated Will be removed in 7.x version. Use `shouldOnce` method instead.
43
58
*/
44
59
public function isOnce (): bool
45
60
{
46
61
return $ this ->once ;
47
62
}
48
63
64
+ /**
65
+ * Determines the type of launch of the deploy operation.
66
+ *
67
+ * If true, then it will be executed once.
68
+ * If false, then the operation will run every time the `operations` command is invoked.
69
+ */
70
+ public function shouldOnce (): bool
71
+ {
72
+ return $ this ->isOnce ();
73
+ }
74
+
49
75
/**
50
76
* Determines a call to database transactions.
77
+ *
78
+ * @deprecated Will be removed in 7.x version. Use `withinTransactions` method instead.
51
79
*/
52
80
public function enabledTransactions (): bool
53
81
{
54
82
return (bool ) config ('deploy-operations.transactions.enabled ' );
55
83
}
56
84
85
+ /**
86
+ * Determines a call to database transactions.
87
+ */
88
+ public function withinTransactions (): bool
89
+ {
90
+ return $ this ->enabledTransactions ();
91
+ }
92
+
57
93
/**
58
94
* The number of attempts to execute a request within a transaction before throwing an error.
95
+ *
96
+ * @deprecated Will be removed in 7.x version. Set the value in the `config/deploy-operations.php` settings file.
59
97
*/
60
98
public function transactionAttempts (): int
61
99
{
@@ -64,14 +102,25 @@ public function transactionAttempts(): int
64
102
65
103
/**
66
104
* Determines which environment to run on.
105
+ *
106
+ * @deprecated Will be removed in 7.x version. Use `withinEnvironment` method instead.
67
107
*/
68
108
public function onEnvironment (): array
69
109
{
70
110
return Arr::wrap ($ this ->environment );
71
111
}
72
112
113
+ public function withinEnvironment (): bool
114
+ {
115
+ $ env = $ this ->onEnvironment ();
116
+
117
+ return empty ($ env ) || in_array (app ()->environment (), $ env , true );
118
+ }
119
+
73
120
/**
74
121
* Determines in which environment it should not run.
122
+ *
123
+ * @deprecated Since with version 7.0 will return `bool`.
75
124
*/
76
125
public function exceptEnvironment (): array
77
126
{
@@ -80,28 +129,58 @@ public function exceptEnvironment(): array
80
129
81
130
/**
82
131
* Determines whether the given operation can be called conditionally.
132
+ *
133
+ * @deprecated Will be removed in 7.x version. Use `shouldRun` method instead.
83
134
*/
84
135
public function allow (): bool
85
136
{
86
137
return true ;
87
138
}
88
139
140
+ /**
141
+ * Determines whether the given operation can be called conditionally.
142
+ */
143
+ public function shouldRun (): bool
144
+ {
145
+ return $ this ->allow ();
146
+ }
147
+
89
148
/**
90
149
* Defines a possible "pre-launch" of the operation.
150
+ *
151
+ * @deprecated Will be removed in 7.x version. Use `needBefore` method instead.
91
152
*/
92
153
public function hasBefore (): bool
93
154
{
94
155
return $ this ->before ;
95
156
}
96
157
158
+ /**
159
+ * Defines a possible "pre-launch" of the operation.
160
+ */
161
+ public function needBefore (): bool
162
+ {
163
+ return $ this ->hasBefore ();
164
+ }
165
+
97
166
/**
98
167
* Defines whether the operation will run synchronously or asynchronously.
168
+ *
169
+ * @deprecated Will be removed in 7.x version. Use `shouldBeAsync` method instead.
99
170
*/
100
171
public function isAsync (): bool
101
172
{
102
173
return (bool ) config ('deploy-operations.async ' );
103
174
}
104
175
176
+ /**
177
+ * Defines whether the operation will run synchronously or asynchronously.
178
+ */
179
+ public function shouldBeAsync (): bool
180
+ {
181
+ return $ this ->isAsync ();
182
+ }
183
+
105
184
/**
106
185
* Method to be called when the job completes successfully.
107
186
*/
0 commit comments