1 | <?php |
||
10 | abstract class Job extends BaseObject implements JobInterface |
||
11 | { |
||
12 | public function init() |
||
13 | { |
||
14 | parent::init(); |
||
15 | Yii::$app->queue->on(Queue::EVENT_AFTER_PUSH, function ($event) { |
||
16 | $delay=$event->delay>=0 ?$event->delay : 0; |
||
17 | $queue = new QueueDb(); |
||
18 | $queue->name=$this->getName(); |
||
|
|||
19 | $queue->catalog=$this->getCatalog(); |
||
20 | $queue->description=$this->getDescription(); |
||
21 | $queue->exec_time=$delay + time(); |
||
22 | $queue->queue_id=$event->id; |
||
23 | $queue->save(); |
||
24 | }); |
||
25 | //增加错误日志 |
||
26 | Yii::$app->queue->on(Queue::EVENT_AFTER_ERROR, function (ErrorEvent $event) { |
||
27 | if ($event->job instanceof \graychen\yii2\queue\backend\jobs\ BaseObject) { |
||
28 | $model = Queue::findOne(['queue_id'=>$event->id]); |
||
29 | $model->log = $event->error; |
||
30 | $model->save(); |
||
31 | } |
||
32 | }); |
||
33 | } |
||
34 | |||
35 | /** name (任务名称) |
||
36 | * @return string |
||
37 | */ |
||
38 | abstract public function getName(); |
||
39 | |||
40 | /** catalog (类别: 推送任务, 上传报告) |
||
41 | * @return string |
||
42 | */ |
||
43 | abstract public function getCatalog(); |
||
44 | |||
45 | /** description (队列详情) |
||
46 | * @return string |
||
47 | */ |
||
48 | abstract public function getDescription(); |
||
49 | } |
||
50 |
Since your code implements the magic setter
_set
, this function will be called for any write access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.