File tree Expand file tree Collapse file tree 3 files changed +8
-27
lines changed Expand file tree Collapse file tree 3 files changed +8
-27
lines changed Original file line number Diff line number Diff line change @@ -127,20 +127,15 @@ protected function storeOperation(OneTimeOperationFile $operationFile): void
127127 return ;
128128 }
129129
130- Operation::storeOperation ($ operationFile ->getOperationName (), $ operationFile -> getClassObject ()-> isAsync ( ));
130+ Operation::storeOperation ($ operationFile ->getOperationName (), $ this -> isAsyncMode ( $ operationFile ));
131131 }
132132
133- protected function processOperation (OneTimeOperationFile $ operationInstance )
133+ protected function processOperation (OneTimeOperationFile $ operationFile )
134134 {
135- $ operation = $ operationInstance ->getClassObject ();
136-
137- $ this ->forceAsync && $ operation ->setAsync ();
138- $ this ->forceSync && $ operation ->setSync ();
139-
140- if ($ operation ->isAsync ()) {
141- OneTimeOperationProcessJob::dispatch ($ operationInstance ->getOperationName ());
135+ if ($ this ->isAsyncMode ($ operationFile )) {
136+ OneTimeOperationProcessJob::dispatch ($ operationFile ->getOperationName ());
142137 } else {
143- OneTimeOperationProcessJob::dispatchSync ($ operationInstance ->getOperationName ());
138+ OneTimeOperationProcessJob::dispatchSync ($ operationFile ->getOperationName ());
144139 }
145140 }
146141
@@ -156,7 +151,7 @@ protected function displayTestmodeWarning(): void
156151 }
157152 }
158153
159- protected function isAsyncMode (bool $ fallback ): bool
154+ protected function isAsyncMode (OneTimeOperationFile $ operationFile ): bool
160155 {
161156 if ($ this ->forceAsync ) {
162157 return true ;
@@ -166,6 +161,6 @@ protected function isAsyncMode(bool $fallback): bool
166161 return false ;
167162 }
168163
169- return $ fallback ;
164+ return $ operationFile -> getClassObject ()-> isAsync () ;
170165 }
171166}
Original file line number Diff line number Diff line change @@ -14,20 +14,6 @@ abstract class OneTimeOperation
1414 */
1515 abstract public function process (): void ;
1616
17- public function setAsync (): self
18- {
19- $ this ->async = true ;
20-
21- return $ this ;
22- }
23-
24- public function setSync (): self
25- {
26- $ this ->async = false ;
27-
28- return $ this ;
29- }
30-
3117 public function isAsync (): bool
3218 {
3319 return $ this ->async ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ public function test_the_whole_command_process()
2727 // create operation file
2828 $ this ->artisan ('operations:make AwesomeOperation ' )
2929 ->assertSuccessful ()
30- ->expectsOutputToContain ('One-time- operation [2015_10_21_072800_awesome_operation] created successfully. ' );
30+ ->expectsOutputToContain ('One-time operation [2015_10_21_072800_awesome_operation] created successfully. ' );
3131
3232 // file was created, but no operation entry yet
3333 $ this ->assertFileExists ($ filepath );
You can’t perform that action at this time.
0 commit comments