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.

31 lines
598 B

7 years ago
<?php
namespace core\jobs;
3 years ago
use Yii;
use yii\base\InvalidConfigException;
7 years ago
use yii\queue\JobInterface;
3 years ago
use yii\queue\Queue;
7 years ago
abstract class Job implements JobInterface
{
3 years ago
/**
* @param Queue $queue
* @throws InvalidConfigException
*/
7 years ago
public function execute($queue): void
{
$listener = $this->resolveHandler();
$listener($this, $queue);
}
3 years ago
/**
* @return callable
* @throws InvalidConfigException
*/
7 years ago
private function resolveHandler(): callable
{
3 years ago
return [Yii::createObject(static::class . 'Handler'), 'handle'];
7 years ago
}
3 years ago
}