From 778c9d82126560980d6473a708cd45c8ee0ba330 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 19 Feb 2017 12:00:35 -0500 Subject: Allow people to remove missing automatic actions When an automatic action is installed from a plugin, if the plugin is removed the automatic could stay in the database if the user didn't remove manually the automatic action. --- app/Core/Action/ActionManager.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'app/Core') diff --git a/app/Core/Action/ActionManager.php b/app/Core/Action/ActionManager.php index aec9ef02..3a77084d 100644 --- a/app/Core/Action/ActionManager.php +++ b/app/Core/Action/ActionManager.php @@ -2,6 +2,7 @@ namespace Kanboard\Core\Action; +use Exception; use RuntimeException; use Kanboard\Core\Base; use Kanboard\Action\Base as ActionBase; @@ -84,8 +85,12 @@ class ActionManager extends Base $params = array(); foreach ($actions as $action) { - $currentAction = $this->getAction($action['action_name']); - $params[$currentAction->getName()] = $currentAction->getActionRequiredParameters(); + try { + $currentAction = $this->getAction($action['action_name']); + $params[$currentAction->getName()] = $currentAction->getActionRequiredParameters(); + } catch (Exception $e) { + $this->logger->error(__METHOD__.': '.$e->getMessage()); + } } return $params; @@ -127,14 +132,18 @@ class ActionManager extends Base } foreach ($actions as $action) { - $listener = clone $this->getAction($action['action_name']); - $listener->setProjectId($action['project_id']); + try { + $listener = clone $this->getAction($action['action_name']); + $listener->setProjectId($action['project_id']); - foreach ($action['params'] as $param_name => $param_value) { - $listener->setParam($param_name, $param_value); - } + foreach ($action['params'] as $param_name => $param_value) { + $listener->setParam($param_name, $param_value); + } - $this->dispatcher->addListener($action['event_name'], array($listener, 'execute')); + $this->dispatcher->addListener($action['event_name'], array($listener, 'execute')); + } catch (Exception $e) { + $this->logger->error(__METHOD__.': '.$e->getMessage()); + } } return $this; -- cgit v1.2.3