summaryrefslogtreecommitdiff
path: root/app/Decorator
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-09-08 22:33:16 -0400
committerFrederic Guillot <fred@kanboard.net>2016-09-08 22:33:16 -0400
commit75470c72428c8d8f278d160369558ab31b137fb1 (patch)
tree7fcad6cbc661e2762f1dfa5f643a5beac5217a17 /app/Decorator
parentfedf4ea2de21fcf95fc5aa942cedc7924865f160 (diff)
Apply column restrictions to the board
Diffstat (limited to 'app/Decorator')
-rw-r--r--app/Decorator/ColumnMoveRestrictionCacheDecorator.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/app/Decorator/ColumnMoveRestrictionCacheDecorator.php b/app/Decorator/ColumnMoveRestrictionCacheDecorator.php
new file mode 100644
index 00000000..331bdebb
--- /dev/null
+++ b/app/Decorator/ColumnMoveRestrictionCacheDecorator.php
@@ -0,0 +1,57 @@
+<?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 column Ids
+ * @param int $project_id
+ * @return array|mixed
+ */
+ public function getAllSrcColumns($project_id)
+ {
+ $key = $this->cachePrefix.$project_id;
+ $columnIds = $this->cache->get($key);
+
+ if ($columnIds === null) {
+ $columnIds = $this->columnMoveRestrictionModel->getAllSrcColumns($project_id);
+ $this->cache->set($key, $columnIds);
+ }
+
+ return $columnIds;
+ }
+}