8000 Fix scheduler examples · symfony/symfony-docs@286959d · GitHub
[go: up one dir, main page]

Skip to content

Commit 286959d

Browse files
committed
Fix scheduler examples
1 parent 8ac82c9 commit 286959d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed
< 8000 div role="region" aria-labelledby="heading-:Rtlab:" class="position-relative" style="contain:layout">

scheduler.rst

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ the task of creating a report::
4848

4949
class SendDailySalesReports
5050
{
51-
public function __construct(private string $id) {}
51+
public function __construct(private int $id) {}
5252

5353
public function getId(): int
5454
{
@@ -61,6 +61,9 @@ Next, create the handler that processes that kind of message::
6161
// src/Scheduler/Handler/SendDailySalesReportsHandler.php
6262
namespace App\Scheduler\Handler;
6363

64+
use App\Scheduler\Message\SendDailySalesReports;
65+
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
66+
6467
#[AsMessageHandler]
6568
class SendDailySalesReportsHandler
6669
{
@@ -105,9 +108,13 @@ The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsSchedule` attribute,
105108
which by default references the schedule named ``default``, allows you to register
106109
on a particular schedule::
107110

108-
// src/Scheduler/MyScheduleProvider.php
111+
// src/Scheduler/SaleTaskProvider.php
109112
namespace App\Scheduler;
110113

114+
use Symfony\Component\Scheduler\Attribute\AsSchedule;
115+
use Symfony\Component\Scheduler\Schedule;
116+
use Symfony\Component\Scheduler\ScheduleProviderInterface;
117+
111118
#[AsSchedule]
112119
class SaleTaskProvider implements ScheduleProviderInterface
113120
{
@@ -260,7 +267,7 @@ Then, define your recurring message::
260267

261268
Finally, the recurring messages has to be attached to a schedule::
262269

263-
// src/Scheduler/MyScheduleProvider.php
270+
// src/Scheduler/SaleTaskProvider.php
264271
namespace App\Scheduler;
265272

266273
#[AsSchedule('uptoyou')]
@@ -344,7 +351,7 @@ via the ``stateful`` option (and the :doc:`Cache component </components/cache>`)
344351
This way, when it wakes up again, it looks at all the dates and can catch up on
345352
what it missed::
346353

347-
// src/Scheduler/MyScheduleProvider.php
354+
// src/Scheduler/SaleTaskProvider.php
348355
namespace App\Scheduler;
349356

350357
#[AsSchedule('uptoyou')]
@@ -366,7 +373,7 @@ To scale your schedules more effectively, you can use multiple workers. In such
366373
cases, a good practice is to add a :doc:`lock </components/lock>` to prevent the
367374
same task more than once::
368375

369-
// src/Scheduler/MyScheduleProvider.php
376+
// src/Scheduler/SaleTaskProvider.php
370377
namespace App\Scheduler;
371378

372379
#[AsSchedule('uptoyou')]
@@ -395,7 +402,7 @@ your message in a :class:`Symfony\\Component\\Messenger\\Message\\RedispatchMess
395402
This allows you to specify a transport on which your message will be redispatched
396403
before being further redispatched to its corresponding handler::
397404

398-
// src/Scheduler/MyScheduleProvider.php
405+
// src/Scheduler/SaleTaskProvider.php
399406
namespace App\Scheduler;
400407

401408
#[AsSchedule('uptoyou')]

0 commit comments

Comments
 (0)
0