@@ -99,8 +99,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
99
99
}
100
100
101
101
foreach ($ this ->taskRepository ->findSystemTasks () as $ task ) {
102
- if (!in_array ($ task ->getSystemKey (), array_keys ($ this ->systemTasks ))) {
103
- $ this ->disableTask ($ task );
102
+ if (!in_array ($ task ->getSystemKey (), array_keys ($ this ->systemTasks )) && ($ this ->disableTask ($ task ))) {
103
+ $ output ->writeln (
104
+ sprintf (' * System-task "%s" was <comment>disabled</comment> ' , $ task ->getSystemKey ())
105
+ );
104
106
}
105
107
}
106
108
@@ -118,17 +120,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
118
120
private function processSystemTask ($ systemKey , array $ systemTask , OutputInterface $ output )
119
121
{
120
122
if (!$ systemTask ['enabled ' ]) {
121
- $ this ->disableSystemTask ($ systemKey );
122
-
123
- $ output -> writeln ( sprintf ( ' * System-task "%s" was <info>disabled</info>. ' , $ systemKey ));
123
+ if ( $ this ->disableSystemTask ($ systemKey )) {
124
+ $ output -> writeln ( sprintf ( ' * System-task "%s" was <comment>disabled</comment> ' , $ systemKey ));
125
+ }
124
126
125
127
return ;
126
128
}
127
129
128
130
if ($ task = $ this ->taskRepository ->findBySystemKey ($ systemKey )) {
129
131
$ this ->updateTask ($ systemKey , $ systemTask , $ task );
130
132
131
- $ output ->writeln (sprintf (' * System-task "%s" was <info>updated</info>. ' , $ systemKey ));
133
+ $ output ->writeln (sprintf (' * System-task "%s" was <info>updated</info> ' , $ systemKey ));
132
134
133
135
return ;
134
136
}
@@ -142,32 +144,39 @@ private function processSystemTask($systemKey, array $systemTask, OutputInterfac
142
144
143
145
$ builder ->schedule ();
144
146
145
- $ output ->writeln (sprintf (' * System-task "%s" was <info>created</info>. ' , $ systemKey ));
147
+ $ output ->writeln (sprintf (' * System-task "%s" was <info>created</info> ' , $ systemKey ));
146
148
}
147
149
148
150
/**
149
151
* Disable task identified by system-key.
150
152
*
151
153
* @param string $systemKey
154
+ *
155
+ * @return bool
152
156
*/
153
157
private function disableSystemTask ($ systemKey )
154
158
{
155
159
if (!$ task = $ this ->taskRepository ->findBySystemKey ($ systemKey )) {
156
- return ;
160
+ return false ;
157
161
}
158
162
159
163
$ this ->disableTask ($ task );
164
+
165
+ return true ;
160
166
}
161
167
162
168
/**
163
169
* Disable given task identified.
164
170
*
165
171
* @param TaskInterface $task
172
+ *
173
+ * @return bool
166
174
*/
167
175
public function disableTask (TaskInterface $ task )
168
176
{
169
177
$ task ->setInterval ($ task ->getInterval (), $ task ->getFirstExecution (), new \DateTime ());
170
- $ this ->abortPending ($ task );
178
+
179
+ return $ this ->abortPending ($ task );
171
180
}
172
181
173
182
/**
@@ -201,14 +210,18 @@ private function updateTask($systemKey, array $systemTask, TaskInterface $task)
201
210
* Abort pending execution for given task.
202
211
*
203
212
* @param TaskInterface $task
213
+ *
214
+ * @return bool
204
215
*/
205
216
private function abortPending (TaskInterface $ task )
206
217
{
207
218
if (!$ execution = $ this ->taskExecutionRepository ->findPending ($ task )) {
208
- return ;
219
+ return false ;
209
220
}
210
221
211
222
$ execution ->setStatus (TaskStatus::ABORTED );
212
223
$ this ->taskExecutionRepository ->save ($ execution );
224
+
225
+ return true ;
213
226
}
214
227
}
0 commit comments