summaryrefslogtreecommitdiff
path: root/app/Core/ExternalTask/ExternalTaskManager.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Core/ExternalTask/ExternalTaskManager.php')
-rw-r--r--app/Core/ExternalTask/ExternalTaskManager.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/app/Core/ExternalTask/ExternalTaskManager.php b/app/Core/ExternalTask/ExternalTaskManager.php
new file mode 100644
index 00000000..2ce6f106
--- /dev/null
+++ b/app/Core/ExternalTask/ExternalTaskManager.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Kanboard\Core\ExternalTask;
+
+/**
+ * Class ExternalTaskManager
+ *
+ * @package Kanboard\Core\ExternalTask
+ * @author Frederic Guillot
+ */
+class ExternalTaskManager
+{
+ protected $providers = array();
+
+ /**
+ * Register a new task provider
+ *
+ * @param ExternalTaskProviderInterface $externalTaskProvider
+ * @return $this
+ */
+ public function register(ExternalTaskProviderInterface $externalTaskProvider)
+ {
+ $this->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);
+ }
+}