summaryrefslogtreecommitdiff
path: root/app/Job/ProjectFileEventJob.php
blob: 45e6ece39b5251390aecd150a328d25674d30c93 (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\ProjectFileEventBuilder;

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

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

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