Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd91780

Browse files
committed
[Scheduler] Add --all to debug:schedule
1 parentbb7a7dd commitdd91780

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

‎src/Symfony/Component/Scheduler/CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CHANGELOG
55
---
66

77
* Mark the component as non experimental
8-
* Add`--date` to`schedule:debug`
8+
* Add`--date`and`--all` optionstothe`schedule:debug` command
99
* Allow setting timezone of next run date in CronExpressionTrigger
1010
* Add`AbstractTriggerDecorator`
1111
* Make`ScheduledStamp` "send-able"

‎src/Symfony/Component/Scheduler/Command/DebugCommand.php‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
useSymfony\Component\Console\Command\Command;
1616
useSymfony\Component\Console\Input\InputArgument;
1717
useSymfony\Component\Console\Input\InputInterface;
18+
useSymfony\Component\Console\Input\InputOption;
1819
useSymfony\Component\Console\Output\OutputInterface;
1920
useSymfony\Component\Console\Style\SymfonyStyle;
2021
useSymfony\Component\Messenger\Envelope;
2122
useSymfony\Component\Scheduler\RecurringMessage;
2223
useSymfony\Component\Scheduler\ScheduleProviderInterface;
2324
useSymfony\Contracts\Service\ServiceProviderInterface;
2425

25-
usefunctionSymfony\Component\Clock\now;
26-
2726
/**
2827
* Command to list/debug schedules.
2928
*
@@ -45,7 +44,8 @@ protected function configure(): void
4544
{
4645
$this
4746
->addArgument('schedule', InputArgument::OPTIONAL | InputArgument::IS_ARRAY,sprintf('The schedule name (one of "%s")',implode('", "',$this->scheduleNames)),null,$this->scheduleNames)
48-
->addOption('date',null, InputArgument::OPTIONAL,'The date to use for the next run date','now')
47+
->addOption('date',null, InputOption::VALUE_REQUIRED,'The date to use for the next run date','now')
48+
->addOption('all',null, InputOption::VALUE_NONE,'Display all recurring messages, including the terminated ones')
4949
->setHelp(<<<'EOF'
5050
The <info>%command.name%</info> lists schedules and their recurring messages:
5151
@@ -59,6 +59,10 @@ protected function configure(): void
5959
6060
<info>php %command.full_name% --date=2025-10-18</info>
6161
62+
To also display the terminated recurring messages, use the <info>--all</info> option:
63+
64+
<info>php %command.full_name% --all</info>
65+
6266
EOF
6367
)
6468
;
@@ -92,17 +96,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9296
}
9397
$io->table(
9498
['Message','Trigger','Next Run'],
95-
array_map(self::renderRecurringMessage(...),$messages,array_fill(0,count($messages),$date)),
99+
array_filter(array_map(self::renderRecurringMessage(...),$messages,array_fill(0,count($messages),$date),array_fill(0,count($messages),$input->getOption('all')))),
96100
);
97101
}
98102

99103
return0;
100104
}
101105

102106
/**
103-
* @return array{0:string,1:string,2:string}
107+
* @return array{0:string,1:string,2:string}|null
104108
*/
105-
privatestaticfunctionrenderRecurringMessage(RecurringMessage$recurringMessage,\DateTimeImmutable$date):array
109+
privatestaticfunctionrenderRecurringMessage(RecurringMessage$recurringMessage,\DateTimeImmutable$date,bool$all):?array
106110
{
107111
$message =$recurringMessage->getMessage();
108112
$trigger =$recurringMessage->getTrigger();
@@ -111,10 +115,12 @@ private static function renderRecurringMessage(RecurringMessage $recurringMessag
111115
$message =$message->getMessage();
112116
}
113117

114-
return [
115-
$messageinstanceof \Stringable ? (string)$message : (new \ReflectionClass($message))->getShortName(),
116-
(string)$trigger,
117-
$trigger->getNextRunDate($date)?->format(\DateTimeInterface::ATOM) ??'-',
118-
];
118+
$next =$trigger->getNextRunDate($date)?->format(\DateTimeInterface::ATOM) ??'-';
119+
if ('-' ===$next && !$all) {
120+
returnnull;
121+
}
122+
$name =$messageinstanceof \Stringable ? (string)$message : (new \ReflectionClass($message))->getShortName();
123+
124+
return [$name, (string)$trigger,$next];
119125
}
120126
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp