Skip to content

Commit ebfda14

Browse files
committed
minor #19935 [Scheduler] Add missing dispatcher in Scheduler example (fabpot)
This PR was merged into the 6.4 branch. Discussion ---------- [Scheduler] Add missing dispatcher in Scheduler example <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `7.x` for features of unreleased versions). --> Commits ------- 008bebf Add missing dispatcher in Scheduler example
2 parents 31de8bc + 008bebf commit ebfda14

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
@@ -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)