blob: 82140d16a8717e19475abdabd1c7cc61bf7409a8 (
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
49
50
51
52
53
54
55
56
57
58
59
|
<?php
namespace Kanboard\Decorator;
use Kanboard\Core\Cache\CacheInterface;
use Kanboard\Model\ColumnMoveRestrictionModel;
/**
* Class ColumnMoveRestrictionCacheDecorator
*
* @package Kanboard\Decorator
* @author Frederic Guillot
*/
class ColumnMoveRestrictionCacheDecorator
{
protected $cachePrefix = 'column_move_restriction:';
/**
* @var CacheInterface
*/
protected $cache;
/**
* @var ColumnMoveRestrictionModel
*/
protected $columnMoveRestrictionModel;
/**
* ColumnMoveRestrictionDecorator constructor.
*
* @param CacheInterface $cache
* @param ColumnMoveRestrictionModel $columnMoveRestrictionModel
*/
public function __construct(CacheInterface $cache, ColumnMoveRestrictionModel $columnMoveRestrictionModel)
{
$this->cache = $cache;
$this->columnMoveRestrictionModel = $columnMoveRestrictionModel;
}
/**
* Proxy method to get sortable columns
*
* @param int $project_id
* @param string $role
* @return array|mixed
*/
public function getSortableColumns($project_id, $role)
{
$key = $this->cachePrefix.$project_id.$role;
$columnIds = $this->cache->get($key);
if ($columnIds === null) {
$columnIds = $this->columnMoveRestrictionModel->getSortableColumns($project_id, $role);
$this->cache->set($key, $columnIds);
}
return $columnIds;
}
}
|