summaryrefslogtreecommitdiff
path: root/app/Job/SubtaskEventJob.php
blob: 1dc243ef2f5022bfe46892db04debebf62a88f78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

namespace Kanboard\Job;

use Kanboard\EventBuilder\SubtaskEventBuilder;

/**
 * Class SubtaskEventJob
 *
 * @package Kanboard\Job
 * @author  Frederic Guillot
 */
class SubtaskEventJob extends BaseJob
{
    /**
     * Set job params
     *
     * @param  int     $subtaskId
     * @param  string  $eventName
     * @param  array   $values
     * @return $this
     */
    public function withParams($subtaskId, $eventName, array $values = array())
    {
        $this->jobParams = array($subtaskId, $eventName, $values);
        return $this;
    }

    /**
     * Execute job
     *
     * @param  int    $subtaskId
     * @param  string $eventName
     * @param  array  $values
     * @return $this
     */
    public function execute($subtaskId, $eventName, array $values = array())
    {
        $event = SubtaskEventBuilder::getInstance($this->container)
            ->withSubtaskId($subtaskId)
            ->withValues($values)
            ->build();

        if ($event !== null) {
            $this->dispatcher->dispatch($eventName, $event);
        }
    }
}