summaryrefslogtreecommitdiff
path: root/app/EventBuilder/CommentEventBuilder.php
blob: 7b4060e41793385bca628d9ff14141fcca134243 (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\EventBuilder;

use Kanboard\Event\CommentEvent;

/**
 * Class CommentEventBuilder
 *
 * @package Kanboard\EventBuilder
 * @author  Frederic Guillot
 */
class CommentEventBuilder extends BaseEventBuilder
{
    protected $commentId = 0;

    /**
     * Set commentId
     *
     * @param  int $commentId
     * @return $this
     */
    public function withCommentId($commentId)
    {
        $this->commentId = $commentId;
        return $this;
    }

    /**
     * Build event data
     *
     * @access public
     * @return CommentEvent|null
     */
    public function build()
    {
        $comment = $this->commentModel->getById($this->commentId);

        if (empty($comment)) {
            return null;
        }

        return new CommentEvent(array(
            'comment' => $comment,
            'task' => $this->taskFinderModel->getDetails($comment['task_id']),
        ));
    }
}