diff --git a/src/Symfony/Component/Scheduler/CHANGELOG.md b/src/Symfony/Component/Scheduler/CHANGELOG.md index 9386daa5a9fd7..c1fa4a6406e7f 100644 --- a/src/Symfony/Component/Scheduler/CHANGELOG.md +++ b/src/Symfony/Component/Scheduler/CHANGELOG.md @@ -5,7 +5,7 @@ CHANGELOG --- * Mark the component as non experimental - * Add `--date` to `schedule:debug` + * Add `--date` and `--all` options to the `schedule:debug` command * Allow setting timezone of next run date in CronExpressionTrigger * Add `AbstractTriggerDecorator` * Make `ScheduledStamp` "send-able" diff --git a/src/Symfony/Component/Scheduler/Command/DebugCommand.php b/src/Symfony/Component/Scheduler/Command/DebugCommand.php index c2510269a3fc2..08b776e1a2924 100644 --- a/src/Symfony/Component/Scheduler/Command/DebugCommand.php +++ b/src/Symfony/Component/Scheduler/Command/DebugCommand.php @@ -15,6 +15,7 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Messenger\Envelope; @@ -22,8 +23,6 @@ use Symfony\Component\Scheduler\ScheduleProviderInterface; use Symfony\Contracts\Service\ServiceProviderInterface; -use function Symfony\Component\Clock\now; - /** * Command to list/debug schedules. * @@ -45,7 +44,8 @@ protected function configure(): void { $this ->addArgument('schedule', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, sprintf('The schedule name (one of "%s")', implode('", "', $this->scheduleNames)), null, $this->scheduleNames) - ->addOption('date', null, InputArgument::OPTIONAL, 'The date to use for the next run date', 'now') + ->addOption('date', null, InputOption::VALUE_REQUIRED, 'The date to use for the next run date', 'now') + ->addOption('all', null, InputOption::VALUE_NONE, 'Display all recurring messages, including the terminated ones') ->setHelp(<<<'EOF' The %command.name% lists schedules and their recurring messages: @@ -59,6 +59,10 @@ protected function configure(): void php %command.full_name% --date=2025-10-18 + To also display the terminated recurring messages, use the --all option: + + php %command.full_name% --all + EOF ) ; @@ -92,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $io->table( ['Message', 'Trigger', 'Next Run'], - array_map(self::renderRecurringMessage(...), $messages, array_fill(0, count($messages), $date)), + array_filter(array_map(self::renderRecurringMessage(...), $messages, array_fill(0, count($messages), $date), array_fill(0, count($messages), $input->getOption('all')))), ); } @@ -100,9 +104,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int } /** - * @return array{0:string,1:string,2:string} + * @return array{0:string,1:string,2:string}|null */ - private static function renderRecurringMessage(RecurringMessage $recurringMessage, \DateTimeImmutable $date): array + private static function renderRecurringMessage(RecurringMessage $recurringMessage, \DateTimeImmutable $date, bool $all): ?array { $message = $recurringMessage->getMessage(); $trigger = $recurringMessage->getTrigger(); @@ -111,10 +115,12 @@ private static function renderRecurringMessage(RecurringMessage $recurringMessag $message = $message->getMessage(); } - return [ - $message instanceof \Stringable ? (string) $message : (new \ReflectionClass($message))->getShortName(), - (string) $trigger, - $trigger->getNextRunDate($date)?->format('r') ?? '-', - ]; + $next = $trigger->getNextRunDate($date)?->format('r') ?? '-'; + if ('-' === $next && !$all) { + return null; + } + $name = $message instanceof \Stringable ? (string) $message : (new \ReflectionClass($message))->getShortName(); + + return [$name, (string) $trigger, $next]; } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy