@@ -2,40 +2,40 @@ |
||
| 2 | 2 | |
| 3 | 3 | $ignoreErrors = []; |
| 4 | 4 | $ignoreErrors[] = [ |
| 5 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<cronExpression\\>, string given\\.$#', |
|
| 6 | - 'identifier' => 'argument.type', |
|
| 7 | - 'count' => 1, |
|
| 8 | - 'path' => __DIR__ . '/src/Commands/Lister.php', |
|
| 5 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<cronExpression\\>, string given\\.$#', |
|
| 6 | + 'identifier' => 'argument.type', |
|
| 7 | + 'count' => 1, |
|
| 8 | + 'path' => __DIR__ . '/src/Commands/Lister.php', |
|
| 9 | 9 | ]; |
| 10 | 10 | $ignoreErrors[] = [ |
| 11 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 12 | - 'identifier' => 'argument.type', |
|
| 13 | - 'count' => 1, |
|
| 14 | - 'path' => __DIR__ . '/src/Commands/Lister.php', |
|
| 11 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 12 | + 'identifier' => 'argument.type', |
|
| 13 | + 'count' => 1, |
|
| 14 | + 'path' => __DIR__ . '/src/Commands/Lister.php', |
|
| 15 | 15 | ]; |
| 16 | 16 | $ignoreErrors[] = [ |
| 17 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 18 | - 'identifier' => 'argument.type', |
|
| 19 | - 'count' => 1, |
|
| 20 | - 'path' => __DIR__ . '/src/Commands/Run.php', |
|
| 17 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 18 | + 'identifier' => 'argument.type', |
|
| 19 | + 'count' => 1, |
|
| 20 | + 'path' => __DIR__ . '/src/Commands/Run.php', |
|
| 21 | 21 | ]; |
| 22 | 22 | $ignoreErrors[] = [ |
| 23 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<cronExpression\\>, string given\\.$#', |
|
| 24 | - 'identifier' => 'argument.type', |
|
| 25 | - 'count' => 1, |
|
| 26 | - 'path' => __DIR__ . '/src/Task.php', |
|
| 23 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<cronExpression\\>, string given\\.$#', |
|
| 24 | + 'identifier' => 'argument.type', |
|
| 25 | + 'count' => 1, |
|
| 26 | + 'path' => __DIR__ . '/src/Task.php', |
|
| 27 | 27 | ]; |
| 28 | 28 | $ignoreErrors[] = [ |
| 29 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<httpclient\\>, string given\\.$#', |
|
| 30 | - 'identifier' => 'argument.type', |
|
| 31 | - 'count' => 1, |
|
| 32 | - 'path' => __DIR__ . '/src/Task.php', |
|
| 29 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<httpclient\\>, string given\\.$#', |
|
| 30 | + 'identifier' => 'argument.type', |
|
| 31 | + 'count' => 1, |
|
| 32 | + 'path' => __DIR__ . '/src/Task.php', |
|
| 33 | 33 | ]; |
| 34 | 34 | $ignoreErrors[] = [ |
| 35 | - 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 36 | - 'identifier' => 'argument.type', |
|
| 37 | - 'count' => 1, |
|
| 38 | - 'path' => __DIR__ . '/src/TaskRunner.php', |
|
| 35 | + 'message' => '#^Parameter \\#1 \\$name of function service expects class\\-string\\<scheduler\\>, string given\\.$#', |
|
| 36 | + 'identifier' => 'argument.type', |
|
| 37 | + 'count' => 1, |
|
| 38 | + 'path' => __DIR__ . '/src/TaskRunner.php', |
|
| 39 | 39 | ]; |
| 40 | 40 | |
| 41 | 41 | return ['parameters' => ['ignoreErrors' => $ignoreErrors]]; |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Scheduler |
| 20 | 20 | { |
| 21 | - const SUNDAY = 0; |
|
| 21 | + const SUNDAY = 0; |
|
| 22 | 22 | |
| 23 | 23 | const MONDAY = 1; |
| 24 | 24 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | return $this->daily($time); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - /** |
|
| 71 | + /** |
|
| 72 | 72 | * S'exécute tous les jours à minuit, sauf si une chaîne d'heure est transmise (comme 04:08pm) |
| 73 | 73 | */ |
| 74 | 74 | public function daily(?string $time = null): self |
@@ -85,16 +85,16 @@ discard block |
||
| 85 | 85 | return $this; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - /** |
|
| 88 | + /** |
|
| 89 | 89 | * S'execute entre une temps de debut et de fin |
| 90 | 90 | */ |
| 91 | 91 | public function between(string $startTime, string $endTime): self |
| 92 | 92 | { |
| 93 | - [$minStart, $hourStart] = array_map('intval', $this->parseTime($startTime)); |
|
| 94 | - [$minEnd, $hourEnd] = array_map('intval', $this->parseTime($endTime)); |
|
| 93 | + [$minStart, $hourStart] = array_map('intval', $this->parseTime($startTime)); |
|
| 94 | + [$minEnd, $hourEnd] = array_map('intval', $this->parseTime($endTime)); |
|
| 95 | 95 | |
| 96 | - $this->betweenHours($hourStart, $hourEnd); |
|
| 97 | - $this->betweenMinutes($minStart, $minEnd); |
|
| 96 | + $this->betweenHours($hourStart, $hourEnd); |
|
| 97 | + $this->betweenMinutes($minStart, $minEnd); |
|
| 98 | 98 | |
| 99 | 99 | return $this; |
| 100 | 100 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | return $this; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - /** |
|
| 136 | + /** |
|
| 137 | 137 | * S'exécute toutes les 2 heures |
| 138 | 138 | * |
| 139 | 139 | * @param int|string|null $minute |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | return $this->everyHour(2, $minute); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - /** |
|
| 146 | + /** |
|
| 147 | 147 | * S'exécute toutes les 3 heures |
| 148 | 148 | * |
| 149 | 149 | * @param int|string|null $minute |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | return $this->everyHour(3, $minute); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - /** |
|
| 156 | + /** |
|
| 157 | 157 | * S'exécute toutes les 4 heures |
| 158 | 158 | * |
| 159 | 159 | * @param int|string|null $minute |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | return $this->everyHour(4, $minute); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - /** |
|
| 166 | + /** |
|
| 167 | 167 | * S'exécute toutes les 6 heures |
| 168 | 168 | * |
| 169 | 169 | * @param int|string|null $minute |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function everyOddHour($minute = null): self |
| 180 | 180 | { |
| 181 | - $this->expression['min'] = $minute ?? '0'; |
|
| 181 | + $this->expression['min'] = $minute ?? '0'; |
|
| 182 | 182 | $this->expression['hour'] = '1-23/2'; |
| 183 | 183 | |
| 184 | 184 | return $this; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | public function everyTenMinutes(): self |
| 261 | 261 | { |
| 262 | - return $this->everyMinute(10); |
|
| 262 | + return $this->everyMinute(10); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | return $this->monthlyOn(1, $time); |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - /** |
|
| 387 | + /** |
|
| 388 | 388 | * S'execute mensuellement à un jour et une heure donnés. |
| 389 | 389 | * |
| 390 | 390 | * @param int<1, 31> $dayOfMonth |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | { |
| 428 | 428 | $this->daily($time); |
| 429 | 429 | |
| 430 | - return $this->daysOfMonth(Date::now()->endOfMonth()->getDay()); |
|
| 430 | + return $this->daysOfMonth(Date::now()->endOfMonth()->getDay()); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -476,11 +476,11 @@ discard block |
||
| 476 | 476 | return $this->quarterlyOn(1, $time); |
| 477 | 477 | } |
| 478 | 478 | |
| 479 | - /** |
|
| 479 | + /** |
|
| 480 | 480 | * S'execute tous les trimestres à un jour et une heure donnés. |
| 481 | 481 | */ |
| 482 | 482 | public function quarterlyOn(int $dayOfQuarter = 1, ?string $time = null) |
| 483 | - { |
|
| 483 | + { |
|
| 484 | 484 | $min = $hour = 0; |
| 485 | 485 | |
| 486 | 486 | if (! empty($time)) { |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | return $this->yearlyOn(1, 1, $time); |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - /** |
|
| 507 | + /** |
|
| 508 | 508 | * S'execute chaque année à un mois, un jour et une heure donnés. |
| 509 | 509 | * |
| 510 | 510 | * @param int<1, 31> $dayOfMonth |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | protected string $timezone; |
| 29 | 29 | |
| 30 | - /** |
|
| 30 | + /** |
|
| 31 | 31 | * Le fuseau horaire global à utiliser. |
| 32 | 32 | */ |
| 33 | 33 | private string $globalTimezone; |
@@ -51,24 +51,24 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | public function __construct(?string $timezone = null) |
| 53 | 53 | { |
| 54 | - if (null === $globalTimezone = config('tasks.timezone')) { |
|
| 55 | - $globalTimezone = config('app.timezone'); |
|
| 56 | - } |
|
| 54 | + if (null === $globalTimezone = config('tasks.timezone')) { |
|
| 55 | + $globalTimezone = config('app.timezone'); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - $this->globalTimezone = $globalTimezone; |
|
| 58 | + $this->globalTimezone = $globalTimezone; |
|
| 59 | 59 | |
| 60 | 60 | $this->setTimezone($timezone); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Définit le fuseau horaire global pour toutes les tâches de construction. |
|
| 65 | - */ |
|
| 66 | - public function setTimezone(?string $timezone = null): self |
|
| 67 | - { |
|
| 68 | - $this->timezone = $timezone ?? $this->globalTimezone; |
|
| 63 | + /** |
|
| 64 | + * Définit le fuseau horaire global pour toutes les tâches de construction. |
|
| 65 | + */ |
|
| 66 | + public function setTimezone(?string $timezone = null): self |
|
| 67 | + { |
|
| 68 | + $this->timezone = $timezone ?? $this->globalTimezone; |
|
| 69 | 69 | |
| 70 | - return $this; |
|
| 71 | - } |
|
| 70 | + return $this; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Vérifie si l'expression cron doit être exécutée. Permet d'utiliser un fuseau horaire personnalisé pour une tâche spécifique |
@@ -25,52 +25,52 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | trait HooksTrait |
| 27 | 27 | { |
| 28 | - /** |
|
| 28 | + /** |
|
| 29 | 29 | * L'emplacement où la sortie doit être envoyée. |
| 30 | 30 | */ |
| 31 | 31 | public ?string $location = null; |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Code de sortie de la tache |
|
| 35 | - */ |
|
| 36 | - protected ?int $exitCode = null; |
|
| 33 | + /** |
|
| 34 | + * Code de sortie de la tache |
|
| 35 | + */ |
|
| 36 | + protected ?int $exitCode = null; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | + /** |
|
| 39 | 39 | * Exception levée lors de l'exécution de la tâche. |
| 40 | 40 | */ |
| 41 | - protected ?Throwable $exception = null; |
|
| 41 | + protected ?Throwable $exception = null; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | + /** |
|
| 44 | 44 | * Indique si la sortie doit être ajoutée. |
| 45 | 45 | */ |
| 46 | 46 | public bool $shouldAppendOutput = false; |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Tableau de rappels à exécuter avant l'execution de la tâche. |
| 50 | - * |
|
| 51 | - * @var list<Closure> |
|
| 50 | + * |
|
| 51 | + * @var list<Closure> |
|
| 52 | 52 | */ |
| 53 | 53 | protected array $beforeCallbacks = []; |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * Tableau de rappels à exécuter après l'execution de la tâche. |
| 57 | - * |
|
| 58 | - * @var list<Closure> |
|
| 57 | + * |
|
| 58 | + * @var list<Closure> |
|
| 59 | 59 | */ |
| 60 | 60 | protected $afterCallbacks = []; |
| 61 | 61 | |
| 62 | - /** |
|
| 62 | + /** |
|
| 63 | 63 | * Met la sortie de la tâche dans un fichier donné. |
| 64 | 64 | */ |
| 65 | 65 | public function sendOutputTo(string $location, bool $append = false): self |
| 66 | 66 | { |
| 67 | - $this->location = $location; |
|
| 68 | - $this->shouldAppendOutput = $append; |
|
| 67 | + $this->location = $location; |
|
| 68 | + $this->shouldAppendOutput = $append; |
|
| 69 | 69 | |
| 70 | 70 | return $this; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - /** |
|
| 73 | + /** |
|
| 74 | 74 | * Ajoute la sortie de la tâche à la fin d'un fichier donné. |
| 75 | 75 | */ |
| 76 | 76 | public function appendOutputTo(string $location): self |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | return $this->sendOutputTo($location, true); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - /** |
|
| 81 | + /** |
|
| 82 | 82 | * Envoi le resultat de l'execution de la tache par mail. |
| 83 | 83 | * |
| 84 | 84 | * @param array|mixed $addresses |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | }); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - /** |
|
| 127 | + /** |
|
| 128 | 128 | * Enregistre un callback à appeler avant l'opération. |
| 129 | 129 | */ |
| 130 | 130 | public function before(Closure $callback): self |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | return $this; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - /** |
|
| 155 | + /** |
|
| 156 | 156 | * Enregistre un callback à appeler si l'opération se deroulle avec succes. |
| 157 | 157 | */ |
| 158 | 158 | public function onSuccess(Closure $callback): self |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | }); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - /** |
|
| 167 | + /** |
|
| 168 | 168 | * Enregistre un callback à appeler si l'opération ne se deroulle pas correctement. |
| 169 | 169 | */ |
| 170 | 170 | public function onFailure(Closure $callback): self |
@@ -176,28 +176,28 @@ discard block |
||
| 176 | 176 | }); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Procede a l'execution de la tache |
|
| 181 | - */ |
|
| 182 | - protected function process(ContainerInterface $container, $method): mixed |
|
| 183 | - { |
|
| 184 | - ob_start(); |
|
| 179 | + /** |
|
| 180 | + * Procede a l'execution de la tache |
|
| 181 | + */ |
|
| 182 | + protected function process(ContainerInterface $container, $method): mixed |
|
| 183 | + { |
|
| 184 | + ob_start(); |
|
| 185 | 185 | |
| 186 | - $result = $this->start($this->container, $method); |
|
| 186 | + $result = $this->start($this->container, $method); |
|
| 187 | 187 | |
| 188 | - // if (! $this->runInBackground) { |
|
| 189 | - $result = $this->finish($this->container, $result); |
|
| 188 | + // if (! $this->runInBackground) { |
|
| 189 | + $result = $this->finish($this->container, $result); |
|
| 190 | 190 | |
| 191 | - ob_end_flush(); |
|
| 191 | + ob_end_flush(); |
|
| 192 | 192 | |
| 193 | - return $result; |
|
| 193 | + return $result; |
|
| 194 | 194 | // } |
| 195 | - } |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - /** |
|
| 197 | + /** |
|
| 198 | 198 | * Demarre l'execution de la tache |
| 199 | - * |
|
| 200 | - * @return mixed Le resultat de l'execution de la tache |
|
| 199 | + * |
|
| 200 | + * @return mixed Le resultat de l'execution de la tache |
|
| 201 | 201 | * |
| 202 | 202 | * @throws Throwable |
| 203 | 203 | */ |
@@ -208,30 +208,30 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | return $this->execute($container, $runMethod); |
| 210 | 210 | } catch (Throwable $e) { |
| 211 | - $this->registerException($e); |
|
| 211 | + $this->registerException($e); |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - /** |
|
| 215 | + /** |
|
| 216 | 216 | * Execute la tache. |
| 217 | - * |
|
| 218 | - * @return mixed Le resultat de l'execution de la tache |
|
| 217 | + * |
|
| 218 | + * @return mixed Le resultat de l'execution de la tache |
|
| 219 | 219 | */ |
| 220 | 220 | protected function execute(ContainerInterface $container, string $runMethod): mixed |
| 221 | 221 | { |
| 222 | - try { |
|
| 223 | - $result = $this->{$runMethod}(); |
|
| 224 | - |
|
| 225 | - if (is_int($result)) { |
|
| 226 | - $this->exitCode = $result; |
|
| 227 | - } else { |
|
| 228 | - $this->exitCode = EXIT_SUCCESS; |
|
| 229 | - } |
|
| 230 | - } catch (Throwable $e) { |
|
| 231 | - $this->registerException($e); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - return $result ?? null; |
|
| 222 | + try { |
|
| 223 | + $result = $this->{$runMethod}(); |
|
| 224 | + |
|
| 225 | + if (is_int($result)) { |
|
| 226 | + $this->exitCode = $result; |
|
| 227 | + } else { |
|
| 228 | + $this->exitCode = EXIT_SUCCESS; |
|
| 229 | + } |
|
| 230 | + } catch (Throwable $e) { |
|
| 231 | + $this->registerException($e); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + return $result ?? null; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -242,12 +242,12 @@ discard block |
||
| 242 | 242 | try { |
| 243 | 243 | $output = $this->callAfterCallbacks($container, $result); |
| 244 | 244 | } finally { |
| 245 | - if (isset($output) && $output !== '' && $this->location !== null) { |
|
| 246 | - @file_put_contents($this->location, $output, $this->shouldAppendOutput ? FILE_APPEND : 0); |
|
| 247 | - } |
|
| 245 | + if (isset($output) && $output !== '' && $this->location !== null) { |
|
| 246 | + @file_put_contents($this->location, $output, $this->shouldAppendOutput ? FILE_APPEND : 0); |
|
| 247 | + } |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - return $result; |
|
| 250 | + return $result; |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | /** |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | return; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - $mailer->to($addresses)->subject($this->getEmailSubject())->text($text)->send(); |
|
| 276 | + $mailer->to($addresses)->subject($this->getEmailSubject())->text($text)->send(); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | return "Sortie de la tâche planifiée pour [{$this->command}]"; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - /** |
|
| 287 | + /** |
|
| 288 | 288 | * Appelle tous les callbacks qui doivent être lancer "avant" l'exécution de la tâche. |
| 289 | 289 | */ |
| 290 | 290 | protected function callBeforeCallbacks(ContainerInterface $container): void |
@@ -294,27 +294,27 @@ discard block |
||
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - /** |
|
| 297 | + /** |
|
| 298 | 298 | * Appelle tous les callbacks qui doivent être lancer "apres" l'exécution de la tâche. |
| 299 | 299 | */ |
| 300 | 300 | protected function callAfterCallbacks(ContainerInterface $container, mixed $result = null): string |
| 301 | 301 | { |
| 302 | - $parameters = ['result' => $result]; |
|
| 302 | + $parameters = ['result' => $result]; |
|
| 303 | 303 | |
| 304 | - if ('' !== $output = ob_get_contents() ?: '') { |
|
| 305 | - $parameters['output'] = new Stringable($output); |
|
| 306 | - } |
|
| 304 | + if ('' !== $output = ob_get_contents() ?: '') { |
|
| 305 | + $parameters['output'] = new Stringable($output); |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | 308 | foreach ($this->afterCallbacks as $callback) { |
| 309 | 309 | $container->call($callback, $parameters); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - return $output; |
|
| 312 | + return $output; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | - protected function registerException(Throwable $e) |
|
| 316 | - { |
|
| 317 | - $this->exception = $e; |
|
| 318 | - $this->exitCode = EXIT_ERROR; |
|
| 319 | - } |
|
| 315 | + protected function registerException(Throwable $e) |
|
| 316 | + { |
|
| 317 | + $this->exception = $e; |
|
| 318 | + $this->exitCode = EXIT_ERROR; |
|
| 319 | + } |
|
| 320 | 320 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | class Task |
| 36 | 36 | { |
| 37 | 37 | use FrequenciesTrait; |
| 38 | - use HooksTrait; |
|
| 38 | + use HooksTrait; |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Types d'action supportés |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | protected array $environments = []; |
| 59 | 59 | |
| 60 | - /** |
|
| 60 | + /** |
|
| 61 | 61 | * Timezone dans lequel la tâche doit être traitée. |
| 62 | 62 | */ |
| 63 | 63 | protected ?string $timezone = null; |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | protected array $attributes = []; |
| 71 | 71 | |
| 72 | - protected ContainerInterface $container; |
|
| 72 | + protected ContainerInterface $container; |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * @param string $type Type de l'action en cours. |
| 76 | - * @param mixed $action Le contenu actuel qu'on souhaite executer. |
|
| 76 | + * @param mixed $action Le contenu actuel qu'on souhaite executer. |
|
| 77 | 77 | * |
| 78 | 78 | * @throws TasksException |
| 79 | 79 | */ |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | throw TasksException::invalidTaskType($type); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - $this->container = service('container'); |
|
| 86 | + $this->container = service('container'); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | throw TasksException::invalidTaskType($this->type); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - return $this->process($this->container, $method); |
|
| 129 | + return $this->process($this->container, $method); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | return $this; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Définit le fuseau horaire pour l'exécution de la tâche. |
|
| 164 | - * |
|
| 165 | - * @param string $timezone L'identifiant du fuseau horaire à utiliser pour la tâche. |
|
| 166 | - * Il doit s'agir d'une chaîne de caractères PHP valide (par exemple, 'America/New_York', 'Europe/Paris'). |
|
| 167 | - */ |
|
| 168 | - public function timezone(string $timezone): self |
|
| 169 | - { |
|
| 170 | - $this->timezone = $timezone; |
|
| 171 | - |
|
| 172 | - return $this; |
|
| 173 | - } |
|
| 162 | + /** |
|
| 163 | + * Définit le fuseau horaire pour l'exécution de la tâche. |
|
| 164 | + * |
|
| 165 | + * @param string $timezone L'identifiant du fuseau horaire à utiliser pour la tâche. |
|
| 166 | + * Il doit s'agir d'une chaîne de caractères PHP valide (par exemple, 'America/New_York', 'Europe/Paris'). |
|
| 167 | + */ |
|
| 168 | + public function timezone(string $timezone): self |
|
| 169 | + { |
|
| 170 | + $this->timezone = $timezone; |
|
| 171 | + |
|
| 172 | + return $this; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | 176 | * Renvoie la date à laquelle cette tâche a été exécutée pour la dernière fois. |