summaryrefslogtreecommitdiff
path: root/app/Api
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-03 16:43:13 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-03 16:43:13 -0500
commita296ba5b18487d312acca2513d461a210a460fae (patch)
treee5e22ffa7796a9734ec284826dd313219644a539 /app/Api
parentd578b612ea8853682f65ee74fd08f4893152d87a (diff)
Improve Automatic Actions plugin api
Diffstat (limited to 'app/Api')
-rw-r--r--app/Api/Action.php28
1 files changed, 8 insertions, 20 deletions
diff --git a/app/Api/Action.php b/app/Api/Action.php
index 0ae91f10..bdb5b26e 100644
--- a/app/Api/Action.php
+++ b/app/Api/Action.php
@@ -12,17 +12,17 @@ class Action extends \Kanboard\Core\Base
{
public function getAvailableActions()
{
- return $this->action->getAvailableActions();
+ return $this->actionManager->getAvailableActions();
}
public function getAvailableActionEvents()
{
- return $this->action->getAvailableEvents();
+ return $this->eventManager->getAll();
}
public function getCompatibleActionEvents($action_name)
{
- return $this->action->getCompatibleEvents($action_name);
+ return $this->actionManager->getCompatibleEvents($action_name);
}
public function removeAction($action_id)
@@ -32,22 +32,10 @@ class Action extends \Kanboard\Core\Base
public function getActions($project_id)
{
- $actions = $this->action->getAllByProject($project_id);
-
- foreach ($actions as $index => $action) {
- $params = array();
-
- foreach ($action['params'] as $param) {
- $params[$param['name']] = $param['value'];
- }
-
- $actions[$index]['params'] = $params;
- }
-
- return $actions;
+ return $this->action->getAllByProject($project_id);
}
- public function createAction($project_id, $event_name, $action_name, $params)
+ public function createAction($project_id, $event_name, $action_name, array $params)
{
$values = array(
'project_id' => $project_id,
@@ -63,16 +51,16 @@ class Action extends \Kanboard\Core\Base
}
// Check if the action exists
- $actions = $this->action->getAvailableActions();
+ $actions = $this->actionManager->getAvailableActions();
if (! isset($actions[$action_name])) {
return false;
}
// Check the event
- $action = $this->action->load($action_name, $project_id, $event_name);
+ $action = $this->actionManager->getAction($action_name);
- if (! in_array($event_name, $action->getCompatibleEvents())) {
+ if (! in_array($event_name, $action->getEvents())) {
return false;
}