|
<?php |
|
|
|
namespace Kanboard\Decorator; |
|
|
|
use Kanboard\Core\Cache\CacheInterface; |
|
use Kanboard\Model\ProjectRoleRestrictionModel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProjectRoleRestrictionCacheDecorator |
|
{ |
|
protected $cachePrefix = 'project_restriction:'; |
|
|
|
|
|
|
|
|
|
protected $cache; |
|
|
|
|
|
|
|
|
|
protected $projectRoleRestrictionModel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function __construct(CacheInterface $cache, ProjectRoleRestrictionModel $projectRoleRestrictionModel) |
|
{ |
|
$this->cache = $cache; |
|
$this->projectRoleRestrictionModel = $projectRoleRestrictionModel; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getAllByRole($project_id, $role) |
|
{ |
|
$key = $this->cachePrefix.$project_id.$role; |
|
$projectRestrictions = $this->cache->get($key); |
|
|
|
if ($projectRestrictions === null) { |
|
$projectRestrictions = $this->projectRoleRestrictionModel->getAllByRole($project_id, $role); |
|
$this->cache->set($key, $projectRestrictions); |
|
} |
|
|
|
return $projectRestrictions; |
|
} |
|
} |
|
|