@@ -47,6 +47,7 @@ protected function configure(): void
47
47
{
48
48
$ this
49
49
->addArgument ('schedule ' , InputArgument::OPTIONAL | InputArgument::IS_ARRAY , sprintf ('The schedule name (one of "%s") ' , implode ('", " ' , $ this ->scheduleNames )), null , $ this ->scheduleNames )
50
+ ->addOption ('date ' , null , InputArgument::OPTIONAL , 'The date to use for the next run date ' , 'now ' )
50
51
->setHelp (<<<'EOF'
51
52
The <info>%command.name%</info> lists schedules and their recurring messages:
52
53
@@ -56,6 +57,10 @@ protected function configure(): void
56
57
57
58
<info>php %command.full_name% default</info>
58
59
60
+ You can also specify a date to use for the next run date:
61
+
62
+ <info>php %command.full_name% --date=2025-10-18</info>
63
+
59
64
EOF
60
65
)
61
66
;
@@ -72,6 +77,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
72
77
return 2 ;
73
78
}
74
79
80
+ $ date = new \DateTimeImmutable ($ input ->getOption ('date ' ));
81
+ if ('now ' !== $ input ->getOption ('date ' )) {
82
+ $ io ->comment (sprintf ('All next run dates computed from %s. ' , $ date ->format (\DateTimeInterface::ATOM )));
83
+ }
84
+
75
85
foreach ($ names as $ name ) {
76
86
$ io ->section ($ name );
77
87
@@ -84,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
84
94
}
85
95
$ io ->table (
86
96
['Message ' , 'Trigger ' , 'Next Run ' ],
87
- array_map (self ::renderRecurringMessage (...), $ messages ),
97
+ array_map (self ::renderRecurringMessage (...), $ messages, array_fill ( 0 , count ( $ messages ), $ date ) ),
88
98
);
89
99
}
90
100
@@ -94,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
94
104
/**
95
105
* @return array{0:string,1:string,2:string}
96
106
*/
97
- private static function renderRecurringMessage (RecurringMessage $ recurringMessage ): array
107
+ private static function renderRecurringMessage (RecurringMessage $ recurringMessage, \ DateTimeImmutable $ date ): array
98
108
{
99
109
$ message = $ recurringMessage ->getMessage ();
100
110
$ trigger = $ recurringMessage ->getTrigger ();
@@ -117,7 +127,7 @@ private static function renderRecurringMessage(RecurringMessage $recurringMessag
117
127
return [
118
128
$ messageName ,
119
129
$ triggerName ,
120
- $ recurringMessage ->getTrigger ()->getNextRunDate (now () )?->format(\DateTimeInterface::ATOM ) ?? '- ' ,
130
+ $ recurringMessage ->getTrigger ()->getNextRunDate ($ date )?->format(\DateTimeInterface::ATOM ) ?? '- ' ,
121
131
];
122
132
}
123
133
}
0 commit comments