Allow to extend automatic actions from plugins

This commit is contained in:
Frederic Guillot
2015-09-22 21:17:50 -04:00
parent b4fe1cd526
commit 9523ff44c0
4 changed files with 88 additions and 4 deletions

View File

@@ -30,6 +30,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
*
@@ -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);
}