summaryrefslogtreecommitdiff
path: root/app/Api/Procedure/TaskMetadataProcedure.php
blob: ab6c32d0434a791ffe82b27dc59776650eaa3809 (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
<?php

namespace Kanboard\Api\Procedure;

use Kanboard\Api\Authorization\TaskAuthorization;

/**
 * Class TaskMetadataProcedure
 *
 * @package Kanboard\Api\Procedure
 * @author  Frederic Guillot
 */
class TaskMetadataProcedure extends BaseProcedure
{
    public function getTaskMetadata($task_id)
    {
        TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'getTask', $task_id);
        return (object) $this->taskMetadataModel->getAll($task_id);
    }

    public function getTaskMetadataByName($task_id, $name)
    {
        TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'getTask', $task_id);
        return $this->taskMetadataModel->get($task_id, $name);
    }

    public function saveTaskMetadata($task_id, array $values)
    {
        TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateTask', $task_id);
        return $this->taskMetadataModel->save($task_id, $values);
    }

    public function removeTaskMetadata($task_id, $name)
    {
        TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateTask', $task_id);
        return $this->taskMetadataModel->remove($task_id, $name);
    }
}