Improve Automatic Actions plugin api
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user