You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
523 B

7 years ago
<?php
namespace core\dispatchers;
use core\jobs\AsyncEventJob;
use yii\queue\Queue;
class AsyncEventDispatcher implements EventDispatcher
{
3 years ago
private Queue $queue;
7 years ago
public function __construct(Queue $queue)
{
$this->queue = $queue;
}
public function dispatchAll(array $events): void
{
foreach ($events as $event) {
$this->dispatch($event);
}
}
public function dispatch($event): void
{
$this->queue->push(new AsyncEventJob($event));
}
3 years ago
}