@@ -14,22 +14,35 @@ abstract class Operation
1414 *
1515 * If true, then it will be executed once.
1616 * 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.
1719 */
1820 protected bool $ once = true ;
1921
2022 /**
2123 * Determines which environment to run on.
24+ *
25+ * @deprecated Will be removed in 7.x version. Use `withinEnvironment` method instead.
2226 */
2327 protected array |string |null $ environment = null ;
2428
2529 /**
2630 * Determines in which environment it should not run.
31+ *
32+ * @deprecated Will be removed in 7.x version. Use `exceptEnvironment` method instead.
2733 */
2834 protected array |string |null $ exceptEnvironment = null ;
2935
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+ */
3141 protected bool $ before = true ;
3242
43+ /**
44+ * @deprecated
45+ */
3346 public function getConnection (): ?string
3447 {
3548 return config ('deploy-operations.connection ' );
@@ -40,22 +53,47 @@ public function getConnection(): ?string
4053 *
4154 * If true, then it will be executed once.
4255 * 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.
4358 */
4459 public function isOnce (): bool
4560 {
4661 return $ this ->once ;
4762 }
4863
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+
4975 /**
5076 * Determines a call to database transactions.
77+ *
78+ * @deprecated Will be removed in 7.x version. Use `withinTransactions` method instead.
5179 */
5280 public function enabledTransactions (): bool
5381 {
5482 return (bool ) config ('deploy-operations.transactions.enabled ' );
5583 }
5684
85+ /**
86+ * Determines a call to database transactions.
87+ */
88+ public function withinTransactions (): bool
89+ {
90+ return $ this ->enabledTransactions ();
91+ }
92+
5793 /**
5894 * 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.
5997 */
6098 public function transactionAttempts (): int
6199 {
@@ -64,14 +102,25 @@ public function transactionAttempts(): int
64102
65103 /**
66104 * Determines which environment to run on.
105+ *
106+ * @deprecated Will be removed in 7.x version. Use `withinEnvironment` method instead.
67107 */
68108 public function onEnvironment (): array
69109 {
70110 return Arr::wrap ($ this ->environment );
71111 }
72112
113+ public function withinEnvironment (): bool
114+ {
115+ $ env = $ this ->onEnvironment ();
116+
117+ return empty ($ env ) || in_array (app ()->environment (), $ env , true );
118+ }
119+
73120 /**
74121 * Determines in which environment it should not run.
122+ *
123+ * @deprecated Since with version 7.0 will return `bool`.
75124 */
76125 public function exceptEnvironment (): array
77126 {
@@ -80,28 +129,58 @@ public function exceptEnvironment(): array
80129
81130 /**
82131 * Determines whether the given operation can be called conditionally.
132+ *
133+ * @deprecated Will be removed in 7.x version. Use `shouldRun` method instead.
83134 */
84135 public function allow (): bool
85136 {
86137 return true ;
87138 }
88139
140+ /**
141+ * Determines whether the given operation can be called conditionally.
142+ */
143+ public function shouldRun (): bool
144+ {
145+ return $ this ->allow ();
146+ }
147+
89148 /**
90149 * Defines a possible "pre-launch" of the operation.
150+ *
151+ * @deprecated Will be removed in 7.x version. Use `needBefore` method instead.
91152 */
92153 public function hasBefore (): bool
93154 {
94155 return $ this ->before ;
95156 }
96157
158+ /**
159+ * Defines a possible "pre-launch" of the operation.
160+ */
161+ public function needBefore (): bool
162+ {
163+ return $ this ->hasBefore ();
164+ }
165+
97166 /**
98167 * Defines whether the operation will run synchronously or asynchronously.
168+ *
169+ * @deprecated Will be removed in 7.x version. Use `shouldBeAsync` method instead.
99170 */
100171 public function isAsync (): bool
101172 {
102173 return (bool ) config ('deploy-operations.async ' );
103174 }
104175
176+ /**
177+ * Defines whether the operation will run synchronously or asynchronously.
178+ */
179+ public function shouldBeAsync (): bool
180+ {
181+ return $ this ->isAsync ();
182+ }
183+
105184 /**
106185 * Method to be called when the job completes successfully.
107186 */
0 commit comments