From ae5d31e4c285e0ce672de780fdacff953fe71bba Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 1 Nov 2016 22:18:43 -0400 Subject: Add ExternalTaskManager class --- app/Core/Base.php | 1 + app/Core/ExternalTask/AccessForbiddenException.php | 14 ++++++ app/Core/ExternalTask/ExternalTaskManager.php | 53 ++++++++++++++++++++++ .../ExternalTask/ExternalTaskProviderInterface.php | 50 ++++++++++++++++++++ app/Core/ExternalTask/NotFoundException.php | 15 ++++++ .../ExternalTask/ProviderNotFoundException.php | 15 ++++++ 6 files changed, 148 insertions(+) create mode 100644 app/Core/ExternalTask/AccessForbiddenException.php create mode 100644 app/Core/ExternalTask/ExternalTaskManager.php create mode 100644 app/Core/ExternalTask/ExternalTaskProviderInterface.php create mode 100644 app/Core/ExternalTask/NotFoundException.php create mode 100644 app/Core/ExternalTask/ProviderNotFoundException.php (limited to 'app/Core') diff --git a/app/Core/Base.php b/app/Core/Base.php index 44dfaa39..3dbf47f9 100644 --- a/app/Core/Base.php +++ b/app/Core/Base.php @@ -17,6 +17,7 @@ use Pimple\Container; * @property \Kanboard\Analytic\AverageTimeSpentColumnAnalytic $averageTimeSpentColumnAnalytic * @property \Kanboard\Core\Action\ActionManager $actionManager * @property \Kanboard\Core\ExternalLink\ExternalLinkManager $externalLinkManager + * @property \Kanboard\Core\ExternalTask\ExternalTaskManager $externalTaskManager * @property \Kanboard\Core\Cache\MemoryCache $memoryCache * @property \Kanboard\Core\Cache\BaseCache $cacheDriver * @property \Kanboard\Core\Event\EventManager $eventManager diff --git a/app/Core/ExternalTask/AccessForbiddenException.php b/app/Core/ExternalTask/AccessForbiddenException.php new file mode 100644 index 00000000..a379d812 --- /dev/null +++ b/app/Core/ExternalTask/AccessForbiddenException.php @@ -0,0 +1,14 @@ +providers[$externalTaskProvider->getName()] = $externalTaskProvider; + return $this; + } + + /** + * Get task provider + * + * @param string $name + * @return ExternalTaskProviderInterface|null + * @throws ProviderNotFoundException + */ + public function getProvider($name) + { + if (isset($this->providers[$name])) { + return $this->providers[$name]; + } + + throw new ProviderNotFoundException('Unable to load this provider: '.$name); + } + + /** + * Get list of task providers + * + * @return array + */ + public function getProvidersList() + { + $providers = array_keys($this->providers); + return array_combine($providers, $providers); + } +} diff --git a/app/Core/ExternalTask/ExternalTaskProviderInterface.php b/app/Core/ExternalTask/ExternalTaskProviderInterface.php new file mode 100644 index 00000000..9e672780 --- /dev/null +++ b/app/Core/ExternalTask/ExternalTaskProviderInterface.php @@ -0,0 +1,50 @@ +