summaryrefslogtreecommitdiff
path: root/app/Api/Procedure/ProjectMetaDataProcedure.php
blob: 19e616125559dfda8a79f8ecc03e75d0eb51b364 (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\ProjectAuthorization;

/**
 * Class ProjectMetadataProcedure
 *
 * @package Kanboard\Api\Procedure
 * @author  Frederic Guillot
 */
class ProjectMetadataProcedure extends BaseProcedure
{
    public function getProjectMetadata($project_id)
    {
        ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getProject', $project_id);
        return (object) $this->projectMetadataModel->getAll($project_id);
    }

    public function getProjectMetadataByName($project_id, $name)
    {
        ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getProject', $project_id);
        return $this->projectMetadataModel->get($project_id, $name);
    }

    public function saveProjectMetadata($project_id, array $values)
    {
        ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateProject', $project_id);
        return $this->projectMetadataModel->save($project_id, $values);
    }

    public function removeProjectMetadata($project_id, $name)
    {
        ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateProject', $project_id);
        return $this->projectMetadataModel->remove($project_id, $name);
    }
}