public function SchedulerManager::dispatch in Scheduler 2.x
Same name and namespace in other branches
- 8 src/SchedulerManager.php \Drupal\scheduler\SchedulerManager::dispatch()
Dispatch a Scheduler event.
All Scheduler events should be dispatched through this common function.
Drupal 8.8 and 8.9 use Symfony 3.4 and from Drupal 9.0 the Symfony version is 4.4. Starting with Symfony 4.3 the signature of the event dispatcher function has the parameters swapped round, the event object is first, followed by the event name string. At 9.0 the existing signature has to be used but from 9.1 the parameters must be switched.
Parameters
\Drupal\Component\EventDispatcher\Event $event: The event object.
string $event_name: The text name for the event.
See also
https://www.drupal.org/project/scheduler/issues/3166688
1 call to SchedulerManager::dispatch()
- SchedulerManager::dispatchSchedulerEvent in src/
SchedulerManager.php - Dispatches a Scheduler event for an entity.
File
- src/
SchedulerManager.php, line 133
Class
- SchedulerManager
- Defines a scheduler manager.
Namespace
Drupal\schedulerCode
public function dispatch(Event $event, string $event_name) {
// \Symfony\Component\HttpKernel\Kernel::VERSION will give the symfony
// version. However, testing this does not give the required outcome, we
// need to test the Drupal core version.
// @todo Remove the check when Core 9.1 is the lowest supported version.
if (version_compare(\Drupal::VERSION, '9.1', '>=')) {
// The new way, with $event first.
$this->eventDispatcher
->dispatch($event, $event_name);
}
else {
// Replicate the existing dispatch signature.
$this->eventDispatcher
->dispatch($event_name, $event);
}
}