diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-09-22 21:17:50 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-09-22 21:17:50 -0400 |
commit | 9523ff44c04bf915e8b819ba8502ea5d20127d17 (patch) | |
tree | dc8da8d21c7b87236d929c1f6986351c1fad440b /app/Model | |
parent | b4fe1cd526e0227b49a399e02052beb1d35abd7f (diff) |
Allow to extend automatic actions from plugins
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/Action.php | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/app/Model/Action.php b/app/Model/Action.php index 87058cce..57bd5b0d 100644 --- a/app/Model/Action.php +++ b/app/Model/Action.php @@ -31,6 +31,28 @@ class Action extends Base const TABLE_PARAMS = 'action_has_params'; /** + * Extended actions + * + * @access private + * @var array + */ + private $actions = array(); + + /** + * Extend the list of default actions + * + * @access public + * @param string $className + * @param string $description + * @return Action + */ + public function extendActions($className, $description) + { + $this->actions[$className] = $description; + return $this; + } + + /** * Return the name and description of available actions * * @access public @@ -62,6 +84,8 @@ class Action extends Base 'TaskAssignColorLink' => t('Change task color when using a specific task link'), ); + $values = array_merge($values, $this->actions); + asort($values); return $values; @@ -296,7 +320,7 @@ class Action extends Base */ public function load($name, $project_id, $event) { - $className = '\Action\\'.$name; + $className = $name{0} !== '\\' ? '\Action\\'.$name : $name; return new $className($this->container, $project_id, $event); } |