mirror of
https://github.com/hauke68/Magallanes.git
synced 2026-08-28 10:08:56 +02:00
Allow parameter configuration on the Task configuration definition.
This commit is contained in:
@@ -73,8 +73,8 @@ class Mage_Task_BuiltIn_Releases_Rollback
|
||||
Mage_Console::output('Deployment to <dark_gray>' . $this->getConfig()->getHost() . '</dark_gray> skipped!', 1, 3);
|
||||
|
||||
} else {
|
||||
foreach ($tasksToRun as $taskName) {
|
||||
$task = Mage_Task_Factory::get($taskName, $this->getConfig(), true, 'deploy');
|
||||
foreach ($tasksToRun as $taskData) {
|
||||
$task = Mage_Task_Factory::get($taskData, $this->getConfig(), true, 'deploy');
|
||||
$task->init();
|
||||
Mage_Console::output('Running <purple>' . $task->getName() . '</purple> ... ', 2, false);
|
||||
|
||||
|
||||
+15
-7
@@ -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);
|
||||
|
||||
@@ -4,16 +4,18 @@ abstract class Mage_Task_TaskAbstract
|
||||
protected $_config = null;
|
||||
protected $_inRollback = false;
|
||||
protected $_stage = null;
|
||||
protected $_parameters = array();
|
||||
|
||||
public abstract function getName();
|
||||
|
||||
public abstract function run();
|
||||
|
||||
public final function __construct(Mage_Config $config, $inRollback = false, $stage = null)
|
||||
public final function __construct(Mage_Config $config, $inRollback = false, $stage = null, $parameters = array())
|
||||
{
|
||||
$this->_config = $config;
|
||||
$this->_inRollback = $inRollback;
|
||||
$this->_stage = $stage;
|
||||
$this->_parameters = $parameters;
|
||||
}
|
||||
|
||||
public function inRollback()
|
||||
@@ -35,6 +37,17 @@ abstract class Mage_Task_TaskAbstract
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the a parameter
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParameter($name, $default = null)
|
||||
{
|
||||
return $this->getConfig()->getParameter($name, $default, $this->_parameters);
|
||||
}
|
||||
|
||||
protected final function _runLocalCommand($command, &$output = null)
|
||||
{
|
||||
return Mage_Console::executeCommand($command, $output);
|
||||
|
||||
Reference in New Issue
Block a user