diff options
Diffstat (limited to 'app/Core/Controller/BaseMiddleware.php')
-rw-r--r-- | app/Core/Controller/BaseMiddleware.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/app/Core/Controller/BaseMiddleware.php b/app/Core/Controller/BaseMiddleware.php new file mode 100644 index 00000000..f2862d13 --- /dev/null +++ b/app/Core/Controller/BaseMiddleware.php @@ -0,0 +1,58 @@ +<?php + +namespace Kanboard\Core\Controller; + +use Kanboard\Core\Base; + +/** + * Class BaseMiddleware + * + * @package Kanboard\Core\Controller + * @author Frederic Guillot + */ +abstract class BaseMiddleware extends Base +{ + /** + * @var BaseMiddleware + */ + protected $nextMiddleware = null; + + /** + * Execute middleware + */ + abstract public function execute(); + + /** + * Set next middleware + * + * @param BaseMiddleware $nextMiddleware + * @return BaseMiddleware + */ + public function setNextMiddleware($nextMiddleware) + { + $this->nextMiddleware = $nextMiddleware; + return $this; + } + + /** + * @return BaseMiddleware + */ + public function getNextMiddleware() + { + return $this->nextMiddleware; + } + + /** + * Move to next middleware + */ + public function next() + { + if ($this->nextMiddleware !== null) { + if (DEBUG) { + $this->logger->debug(__METHOD__.' => ' . get_class($this->nextMiddleware)); + } + + $this->nextMiddleware->execute(); + } + } +} |