Skip to content

Commit 008bebf

Browse files
committed
Add missing dispatcher in Scheduler example
1 parent 7fa7670 commit 008bebf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scheduler.rst

+6-2
Original file line numberDiff line numberDiff line change
@@ -652,11 +652,15 @@ being transferred and processed by its handler::
652652
#[AsSchedule('uptoyou')]
653653
class SaleTaskProvider implements ScheduleProviderInterface
654654
{
655+
public function __construct(private EventDispatcherInterface $dispatcher)
656+
{
657+
}
658+
655659
public function getSchedule(): Schedule
656660
{
657661
$this->removeOldReports = RecurringMessage::cron('3 8 * * 1', new CleanUpOldSalesReport());
658662

659-
return $this->schedule ??= (new Schedule())
663+
return $this->schedule ??= (new Schedule($this->dispatcher))
660664
->with(
661665
// ...
662666
)
@@ -671,7 +675,7 @@ being transferred and processed by its handler::
671675
$schedule->removeById($messageContext->id);
672676

673677
// allow to call the ShouldCancel() and avoid the message to be handled
674-
$event->shouldCancel(true);
678+
$event->shouldCancel(true);
675679
})
676680
->after(function(PostRunEvent $event) {
677681
// Do what you want

0 commit comments

Comments
 (0)