summaryrefslogtreecommitdiff
path: root/app/Job/TaskLinkEventJob.php
blob: 31f62f07b836f98cd2bfa2aee2238fd903310b3e (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
<?php

namespace Kanboard\Job;

use Kanboard\EventBuilder\TaskLinkEventBuilder;

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

    /**
     * Execute job
     *
     * @param  int    $taskLinkId
     * @param  string $eventName
     * @return $this
     */
    public function execute($taskLinkId, $eventName)
    {
        $event = TaskLinkEventBuilder::getInstance($this->container)
            ->withTaskLinkId($taskLinkId)
            ->buildEvent();

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