Allow parameter configuration on the Task configuration definition.

This commit is contained in:
Andrés Montañez
2012-09-23 19:33:10 -03:00
parent 811c83e13a
commit 969caa0bbb
8 changed files with 81 additions and 18 deletions
+15 -7
View File
@@ -2,27 +2,35 @@
class Mage_Task_Factory
{
/**
*
*
* @param string $taskName
*
*
* @param string|array $taskData
* @param boolean $inRollback
* @return Mage_Task_TaskAbstract
*/
public static function get($taskName, Mage_Config $taskConfig, $inRollback = false, $stage = null)
public static function get($taskData, Mage_Config $taskConfig, $inRollback = false, $stage = null)
{
if (is_array($taskData)) {
$taskName = $taskData['name'];
$taskParameters = $taskData['parameters'];
} else {
$taskName = $taskData;
$taskParameters = array();
}
$instance = null;
$taskName = ucwords(str_replace('-', ' ', $taskName));
$taskName = str_replace(' ', '', $taskName);
if (strpos($taskName, '/') === false) {
Mage_Autoload::loadUserTask($taskName);
$className = 'Task_' . ucfirst($taskName);
$instance = new $className($taskConfig, $inRollback, $stage);
$instance = new $className($taskConfig, $inRollback, $stage, $taskParameters);
} else {
$taskName = str_replace(' ', '_', ucwords(str_replace('/', ' ', $taskName)));
$className = 'Mage_Task_BuiltIn_' . $taskName;
$instance = new $className($taskConfig, $inRollback, $stage);
$instance = new $className($taskConfig, $inRollback, $stage, $taskParameters);
}
assert($instance instanceOf Mage_Task_TaskAbstract);