33namespace DragonCode \LaravelDeployOperations ;
44
55use DragonCode \LaravelDeployOperations \Concerns \Artisan ;
6- use Illuminate \Support \Arr ;
76
87abstract class Operation
98{
109 use Artisan;
1110
12- /**
13- * Determines the type of launch of the deploy operation.
14- *
15- * If true, then it will be executed once.
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.
19- */
20- protected bool $ once = true ;
21-
22- /**
23- * Determines which environment to run on.
24- *
25- * @deprecated Will be removed in 7.x version. Use `shouldRun` method instead.
26- */
27- protected array |string |null $ environment = null ;
28-
29- /**
30- * Determines in which environment it should not run.
31- *
32- * @deprecated Will be removed in 7.x version. Use `shouldRun` method instead.
33- */
34- protected array |string |null $ exceptEnvironment = null ;
35-
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- */
41- protected bool $ before = true ;
42-
43- /**
44- * @deprecated
45- */
46- public function getConnection (): ?string
47- {
48- return config ('deploy-operations.connection ' );
49- }
50-
51- /**
52- * Determines the type of launch of the deploy operation.
53- *
54- * If true, then it will be executed once.
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.
58- */
59- public function isOnce (): bool
60- {
61- return $ this ->once ;
62- }
63-
6411 /**
6512 * Determines the type of launch of the deploy operation.
6613 *
@@ -69,116 +16,39 @@ public function isOnce(): bool
6916 */
7017 public function shouldOnce (): bool
7118 {
72- return $ this ->isOnce ();
73- }
74-
75- /**
76- * Determines a call to database transactions.
77- *
78- * @deprecated Will be removed in 7.x version. Use `withinTransactions` method instead.
79- */
80- public function enabledTransactions (): bool
81- {
82- return (bool ) config ('deploy-operations.transactions.enabled ' );
19+ return true ;
8320 }
8421
8522 /**
8623 * Determines a call to database transactions.
8724 */
8825 public function withinTransactions (): bool
8926 {
90- return $ this ->enabledTransactions ();
91- }
92-
93- /**
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.
97- */
98- public function transactionAttempts (): int
99- {
100- return config ('deploy-operations.transactions.attempts ' , 1 );
101- }
102-
103- /**
104- * Determines which environment to run on.
105- *
106- * @deprecated Will be removed in 7.x version. Use `shouldRun` method instead.
107- */
108- public function onEnvironment (): array
109- {
110- return Arr::wrap ($ this ->environment );
111- }
112-
113- /**
114- * Determines in which environment it should not run.
115- *
116- * @deprecated Will be removed in 7.x version. Use `shouldRun` method instead.
117- */
118- public function exceptEnvironment (): array
119- {
120- return Arr::wrap ($ this ->exceptEnvironment );
121- }
122-
123- /**
124- * Determines whether the given operation can be called conditionally.
125- *
126- * @deprecated Will be removed in 7.x version. Use `shouldRun` method instead.
127- */
128- public function allow (): bool
129- {
130- return true ;
27+ return (bool ) config ('deploy-operations.transactions.enabled ' );
13128 }
13229
13330 /**
13431 * Determines whether the given operation can be called conditionally.
13532 */
13633 public function shouldRun (): bool
13734 {
138- $ env = app ()->environment ();
139-
140- $ on = $ this ->onEnvironment ();
141- $ except = $ this ->exceptEnvironment ();
142-
143- return $ this ->allow ()
144- && (empty ($ on ) || in_array ($ env , $ on , true ))
145- && (empty ($ except ) || ! in_array ($ env , $ except , true ));
146- }
147-
148- /**
149- * Defines a possible "pre-launch" of the operation.
150- *
151- * @deprecated Will be removed in 7.x version. Use `needBefore` method instead.
152- */
153- public function hasBefore (): bool
154- {
155- return $ this ->before ;
35+ return true ;
15636 }
15737
15838 /**
15939 * Defines a possible "pre-launch" of the operation.
16040 */
16141 public function needBefore (): bool
16242 {
163- return $ this ->hasBefore ();
164- }
165-
166- /**
167- * Defines whether the operation will run synchronously or asynchronously.
168- *
169- * @deprecated Will be removed in 7.x version. Use `shouldBeAsync` method instead.
170- */
171- public function isAsync (): bool
172- {
173- return (bool ) config ('deploy-operations.async ' );
43+ return true ;
17444 }
17545
17646 /**
17747 * Defines whether the operation will run synchronously or asynchronously.
17848 */
17949 public function shouldBeAsync (): bool
18050 {
181- return $ this -> isAsync ( );
51+ return ( bool ) config ( ' deploy-operations.async ' );
18252 }
18353
18454 /**
0 commit comments