PHP code example of wwwision / event-scheduler
1. Go to this page and download the library: Download wwwision/event-scheduler library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wwwision / event-scheduler example snippets
class SomeClass implements EventListenerInterface
{
const TASK_TYPE = 'plans';
/**
* @Flow\Inject
* @var EventScheduler
*/
protected $scheduler;
public function whenSomeThingWasPlanned(SomeThingWasPlanned $event): void
{
$taskPayload = ['nameOfTheThing' => $event->getTitle()];
$this->scheduler->scheduleTask($event->getCorrelationId(), self::TASK_TYPE, $event->getPlannedDate(), $taskPayload);
}
public function whenSomeThingWasCancelled(SomeThingWasCancelled $event): void
{
$this->scheduler->cancelTask($event->getCorrelationId(), self::TASK_TYPE);
}
public function whenSchedulerWasTriggered(SchedulerWasTriggered $event): void
{
if (!$event->matchesType(self::TASK_TYPE)) {
return;
}
$payload = $event->getPayload();
// TODO Do something with the $paload
}
}