1
0
mirror of https://github.com/hauke68/Magallanes.git synced 2025-08-25 21:00:18 +02:00
Magallanes/Mage/Task/Releases.php
Andrs Montaez 9cf720c602 Rollback awareness.
Tasks are aware if they are in rollbacks; they will be invoked only if
they implement the new interface RollbackAware.
2012-01-03 23:25:42 -02:00

60 lines
1.6 KiB
PHP

<?php
class Mage_Task_Releases
{
private $_config = null;
private $_action = null;
private $_release = null;
public function setAction($action)
{
$this->_action = $action;
return $this;
}
public function getAction()
{
return $this->_action;
}
public function setRelease($releaseId)
{
$this->_release = $releaseId;
return $this;
}
public function getRelease()
{
return $this->_release;
}
public function run(Mage_Config $config)
{
$this->_config = $config;
// Run Tasks for Deployment
$hosts = $config->getHosts();
if (count($hosts) == 0) {
Mage_Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>', 1, 3);
} else {
foreach ($hosts as $host) {
$config->setHost($host);
switch ($this->getAction()) {
case 'list':
$task = Mage_Task_Factory::get('releases/list', $config);
$task->init();
$result = $task->run();
break;
case 'rollback':
$task = Mage_Task_Factory::get('releases/rollback', $config);
$task->init();
$task->setRelease($this->getRelease());
$result = $task->run();
break;
}
}
}
}
}