Skip to content

Commit 12689be

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: Add missing dispatcher in Scheduler example
2 parents ee9b514 + ec50e77 commit 12689be

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scheduler.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,15 @@ being transferred and processed by its handler::
624624
#[AsSchedule('uptoyou')]
625625
class SaleTaskProvider implements ScheduleProviderInterface
626626
{
627+
public function __construct(private EventDispatcherInterface $dispatcher)
628+
{
629+
}
630+
627631
public function getSchedule(): Schedule
628632
{
629633
$this->removeOldReports = RecurringMessage::cron('3 8 * * 1', new CleanUpOldSalesReport());
630634

631-
return $this->schedule ??= (new Schedule())
635+
return $this->schedule ??= (new Schedule($this->dispatcher))
632636
->with(
633637
// ...
634638
)
@@ -643,7 +647,7 @@ being transferred and processed by its handler::
643647
$schedule->removeById($messageContext->id);
644648

645649
// allow to call the ShouldCancel() and avoid the message to be handled
646-
$event->shouldCancel(true);
650+
$event->shouldCancel(true);
647651
})
648652
->after(function(PostRunEvent $event) {
649653
// Do what you want

0 commit comments

Comments
 (0)