Browse Source

Merge pull request #95 from voukka/master

Many bug fixes. With this fixes I was able to test my own Tasks! :)
1.0
Andrés Montañez 10 years ago
parent
commit
bf902c9853
  1. 42
      Mage/Autoload.php
  2. 90
      Mage/Command/BuiltIn/DeployCommand.php
  3. 39
      Mage/Command/BuiltIn/ReleasesCommand.php
  4. 12
      Mage/Command/Factory.php
  5. 215
      Mage/Config.php
  6. 13
      Mage/Config/ConfigNotFoundException.php
  7. 13
      Mage/Config/OptionalConfigNotFoundException.php
  8. 13
      Mage/Config/RequiredConfigNotFoundException.php
  9. 24
      Mage/Console.php
  10. 10
      Mage/Task/AbstractTask.php
  11. 3
      Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php
  12. 13
      Mage/Task/Factory.php
  13. 5
      bin/mage

42
Mage/Autoload.php

@ -20,34 +20,40 @@ class Autoload
/** /**
* Autoload a Class by it's Class Name * Autoload a Class by it's Class Name
* @param string $className * @param string $className
* @return boolean
*/ */
public static function autoload($className) public function autoLoad($className)
{ {
$className = ltrim($className, '/');
$postfix = '/' . str_replace(array('_', '\\'), '/', $className . '.php');
//Try to load a normal Mage class (or Task). Think that Mage component is compiled to .phar
$baseDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname(__FILE__));
$classFile = $baseDir . '/' . str_replace(array('_', '\\'), '/', $className . '.php'); $classFileWithinPhar = $baseDir . $postfix;
require_once $classFile; if($this->isReadable($classFileWithinPhar))
{
require_once $classFileWithinPhar;
return true;
} }
/** //Try to load a custom Task or Class. Notice that the path is absolute to CWD
* Checks if a Class can be loaded. $classFileOutsidePhar = getcwd() . '/.mage/tasks' . $postfix;
* @param string $className if($this->isReadable($classFileOutsidePhar)){
* @return boolean require_once $classFileOutsidePhar;
*/ return true;
public static function isLoadable($className) }
{
$baseDir = dirname(dirname(__FILE__)); return false;
$classFile = $baseDir . '/' . str_replace(array('_', '\\'), '/', $className . '.php');
return (file_exists($classFile) && is_readable($classFile));
} }
/** /**
* Loads a User's Tasks * Checks if a file can be read.
* @param string $taskName * @param string $filePath
* @return boolean
*/ */
public static function loadUserTask($taskName) public function isReadable($filePath)
{ {
$classFile = getcwd() . '/.mage/tasks/' . ucfirst($taskName) . '.php'; return is_readable($filePath);
require_once $classFile;
} }
} }

90
Mage/Command/BuiltIn/DeployCommand.php

@ -30,6 +30,14 @@ use Exception;
*/ */
class DeployCommand extends AbstractCommand implements RequiresEnvironment class DeployCommand extends AbstractCommand implements RequiresEnvironment
{ {
const DEFAULT_RELEASE_IS_ENABLED = false;
const DEPLOY_STRATEGY_DISABLED = 'disabled';
const DEPLOY_STRATEGY_RSYNC = 'rsync';
const DEPLOY_STRATEGY_TARGZ = 'targz';
const DEPLOY_STRATEGY_GIT_REBASE = 'git-rebase';
const DEPLOY_STRATEGY_GUESS = 'guess';
const DEFAULT_DEPLOY_STRATEGY = self::DEPLOY_STRATEGY_GUESS;
/** /**
* Deploy has Failed * Deploy has Failed
* @var string * @var string
@ -298,33 +306,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
$tasksToRun = $this->getConfig()->getTasks(); $tasksToRun = $this->getConfig()->getTasks();
// Guess a Deploy Strategy $deployStrategy = $this->chooseDeployStrategy();
switch ($this->getConfig()->deployment('strategy', 'guess')) {
case 'disabled':
$deployStrategy = 'deployment/strategy/disabled';
break;
case 'rsync':
$deployStrategy = 'deployment/strategy/rsync';
break;
case 'targz':
$deployStrategy = 'deployment/strategy/tar-gz';
break;
case 'git-rebase':
$deployStrategy = 'deployment/strategy/git-rebase';
break;
case 'guess':
default:
if ($this->getConfig()->release('enabled', false) == true) {
$deployStrategy = 'deployment/strategy/tar-gz';
} else {
$deployStrategy = 'deployment/strategy/rsync';
}
break;
}
array_unshift($tasksToRun, $deployStrategy); array_unshift($tasksToRun, $deployStrategy);
@ -381,7 +363,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
$this->getConfig()->setHost($host); $this->getConfig()->setHost($host);
$this->getConfig()->setHostConfig($hostConfig); $this->getConfig()->setHostConfig($hostConfig);
$task = Factory::get('deployment/release', $this->getConfig(), false, AbstractTask::STAGE_DEPLOY); $task = Factory::get($this->chooseReleaseStrategy(), $this->getConfig(), false, AbstractTask::STAGE_DEPLOY);
if ($this->runTask($task, 'Releasing on host <purple>' . $host . '</purple> ... ')) { if ($this->runTask($task, 'Releasing on host <purple>' . $host . '</purple> ... ')) {
$completedTasks++; $completedTasks++;
@ -543,4 +525,56 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
return true; return true;
} }
/**
* @return string
*/
protected function chooseDeployStrategy()
{
// Guess a Deploy Strategy
switch ($this->getConfig()->deployment('strategy', self::DEFAULT_DEPLOY_STRATEGY)) {
case self::DEPLOY_STRATEGY_DISABLED:
$deployStrategy = 'deployment/strategy/disabled';
break;
case self::DEPLOY_STRATEGY_RSYNC:
$deployStrategy = 'deployment/strategy/rsync';
break;
case self::DEPLOY_STRATEGY_TARGZ:
$deployStrategy = 'deployment/strategy/tar-gz';
break;
case self::DEPLOY_STRATEGY_GIT_REBASE:
$deployStrategy = 'deployment/strategy/git-rebase';
break;
case self::DEPLOY_STRATEGY_GUESS:
default:
if ($this->getConfig()->release('enabled', false) == true) {
$deployStrategy = 'deployment/strategy/tar-gz';
} else {
$deployStrategy = 'deployment/strategy/rsync';
}
break;
}
return $deployStrategy;
}
/**
* @return string
*/
protected function chooseReleaseStrategy()
{
if ($this->getConfig()->release('enabled', self::DEFAULT_RELEASE_IS_ENABLED)
&& $this->getConfig()->deployment('strategy', self::DEFAULT_DEPLOY_STRATEGY) !== self::DEPLOY_STRATEGY_DISABLED
) {
$strategy = 'deployment/release';
} else {
$strategy = 'deployment/strategy/disabled';
}
return $strategy;
}
} }

39
Mage/Command/BuiltIn/ReleasesCommand.php

@ -28,30 +28,24 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
*/ */
public function run() public function run()
{ {
if (!is_numeric($this->getConfig()->getParameter('release', ''))) { $subCommand = $this->getConfig()->getArgument(1);
Console::output('<red>This release is mandatory.</red>', 1, 2);
return false;
}
$subcommand = $this->getConfig()->getArgument(1);
$lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
if (file_exists($lockFile) && ($subcommand == 'rollback')) {
Console::output('<red>This environment is locked!</red>', 1, 2);
echo file_get_contents($lockFile);
return null;
}
// Run Tasks for Deployment // Run Tasks for Deployment
$hosts = $this->getConfig()->getHosts(); $hosts = $this->getConfig()->getHosts();
if (count($hosts) == 0) { if (count($hosts) == 0) {
Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>', 1, 3); Console::output(
'<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>',
1, 3
);
return false;
}
} else {
foreach ($hosts as $host) { foreach ($hosts as $host) {
$this->getConfig()->setHost($host); $this->getConfig()->setHost($host);
switch ($subcommand) { switch ($subCommand) {
case 'list': case 'list':
$task = Factory::get('releases/list', $this->getConfig()); $task = Factory::get('releases/list', $this->getConfig());
$task->init(); $task->init();
@ -59,6 +53,20 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
break; break;
case 'rollback': case 'rollback':
if (!is_numeric($this->getConfig()->getParameter('release', ''))) {
Console::output('<red>Missing required releaseid.</red>', 1, 2);
return false;
}
$lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
if (file_exists($lockFile)) {
Console::output('<red>This environment is locked!</red>', 1, 2);
echo file_get_contents($lockFile);
return false;
}
$releaseId = $this->getConfig()->getParameter('release', ''); $releaseId = $this->getConfig()->getParameter('release', '');
$task = Factory::get('releases/rollback', $this->getConfig()); $task = Factory::get('releases/rollback', $this->getConfig());
$task->init(); $task->init();
@ -67,7 +75,6 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
break; break;
} }
} }
}
return $result; return $result;
} }

12
Mage/Command/Factory.php

@ -38,18 +38,14 @@ class Factory
$commandName = str_replace(' ', '_', ucwords(str_replace('/', ' ', $commandName))); $commandName = str_replace(' ', '_', ucwords(str_replace('/', ' ', $commandName)));
$className = 'Mage\\Command\\BuiltIn\\' . $commandName . 'Command'; $className = 'Mage\\Command\\BuiltIn\\' . $commandName . 'Command';
if (Autoload::isLoadable($className)) { /** @var AbstractCommand $instance */
$instance = new $className; $instance = new $className;
assert($instance instanceOf AbstractCommand); if(!is_a($instance, "Mage\Command\AbstractCommand")) {
$instance->setConfig($config);
} else {
throw new Exception('Command not found.');
}
if(!($instance instanceOf AbstractCommand)) {
throw new Exception('The command ' . $commandName . ' must be an instance of Mage\Command\AbstractCommand.'); throw new Exception('The command ' . $commandName . ' must be an instance of Mage\Command\AbstractCommand.');
} }
$instance->setConfig($config);
return $instance; return $instance;
} }
} }

215
Mage/Config.php

@ -10,6 +10,10 @@
namespace Mage; namespace Mage;
use Mage\Config\ConfigNotFoundException;
use Mage\Config\RequiredConfigNotFoundException;
use Mage\Console;
use Mage\Yaml\Exception\RuntimeException;
use Mage\Yaml\Yaml; use Mage\Yaml\Yaml;
use Exception; use Exception;
@ -20,6 +24,7 @@ use Exception;
*/ */
class Config class Config
{ {
const HOST_NAME_LENGTH = 1000;
/** /**
* Arguments loaded * Arguments loaded
* @var array * @var array
@ -51,23 +56,20 @@ class Config
private $hostConfig = array(); private $hostConfig = array();
/** /**
* The Relase ID * The Release ID
* @var integer * @var integer
*/ */
private $releaseId = null; private $releaseId = null;
/** /**
* Magallanes Global and Environment configuration * Magallanes Global and Environment configuration
* @var array
*/ */
private $config = array( private $generalConfig = array();
'general' => array(), private $environmentConfig = array();
'environment' => array(),
);
/** /**
* Parse the Command Line options * Parse the Command Line options
* @return boolean * @param $arguments
*/ */
protected function parse($arguments) protected function parse($arguments)
{ {
@ -95,45 +97,112 @@ class Config
} }
/** /**
* Loads the General Configuration * Initializes the General Configuration
*/
protected function initGeneral()
{
try {
$this->generalConfig = $this->loadGeneral(getcwd() . '/.mage/config/general.yml');
} catch (ConfigNotFoundException $e) {
// normal situation
}
}
/**
* Load general config from the given file
*
* @param $filePath
*
* @return array
* @throws Config\ConfigNotFoundException
*/
protected function loadGeneral($filePath){
return $this->parseConfigFile($filePath);
}
/**
* Obviously this method is a HACK. It was refactored from ::loadEnvironment()
* TODO Please put it to SCM functionality.
*
* @param array $settings
*
* @return array
*/ */
protected function loadGeneral() protected function updateSCMTempDir(array $settings)
{ {
if (file_exists(getcwd() . '/.mage/config/general.yml')) { // Create temporal directory for clone
$this->config['general'] = Yaml::parse(file_get_contents(getcwd() . '/.mage/config/general.yml')); if (isset($settings['deployment']['source']) && is_array($settings['deployment']['source'])) {
if (trim($settings['deployment']['source']['temporal']) == '') {
$settings['deployment']['source']['temporal'] = sys_get_temp_dir();
} }
$settings['deployment']['source']['temporal']
= rtrim($settings['deployment']['source']['temporal'], '/') . '/' . md5(microtime()) . '/';
} }
return $settings;
}
/** /**
* Loads the Environment configuration * Loads the Environment configuration
* @param $filePath string
*
* @throws Exception
* @return boolean
*/
protected function loadEnvironment($filePath)
{
$settings = $this->parseConfigFile($filePath);
//this is a HACK in the old code - no time to remove it now, so I factored it out in own method
$settings = $this->updateSCMTempDir($settings);
return $settings;
}
/**
* Initializes the Environment configuration
* *
* @throws Exception * @throws Exception
* @return boolean * @return boolean
*/ */
protected function loadEnvironment() protected function initEnvironment()
{ {
$environment = $this->getEnvironment(); $environment = $this->getEnvironment();
if (($environment != false) && file_exists(getcwd() . '/.mage/config/environment/' . $environment . '.yml')) {
$this->config['environment'] = Yaml::parse(file_get_contents(getcwd() . '/.mage/config/environment/' . $environment . '.yml'));
// Create temporal directory for clone if(!empty($environment))
if (isset($this->config['environment']['deployment']['source']) && is_array($this->config['environment']['deployment']['source'])) { {
if (trim($this->config['environment']['deployment']['source']['temporal']) == '') { $configFilePath = getcwd() . '/.mage/config/environment/' . $environment . '.yml';
$this->config['environment']['deployment']['source']['temporal'] = '/tmp';
try {
$this->environmentConfig = $this->loadEnvironment($configFilePath);
} catch (ConfigNotFoundException $e) {
throw new RequiredConfigNotFoundException("Not found required config $configFilePath for environment $environment", 0 , $e);
}
} }
$newTemporal = rtrim($this->config['environment']['deployment']['source']['temporal'], '/')
. '/' . md5(microtime()) . '/';
$this->config['environment']['deployment']['source']['temporal'] = $newTemporal;
} }
return true;
} else if (($environment != '') && !file_exists(getcwd() . '/.mage/config/environment/' . $environment . '.yml')) { /**
throw new Exception('Environment does not exists.'); *
* @param array $parameters
* @return boolean
*/
protected function isRunInSpecialMode(array $parameters)
{
if(empty($parameters))
return true;
foreach($parameters as $parameter)
{
if(isset(Console::$paramsNotRequiringEnvironment[$parameter]))
{
return true;
}
} }
return false; return false;
} }
/** /**
* Load the Configuration and parses the Arguments * Load the Configuration and parses the Arguments
* *
@ -142,8 +211,8 @@ class Config
public function load($arguments) public function load($arguments)
{ {
$this->parse($arguments); $this->parse($arguments);
$this->loadGeneral(); $this->initGeneral();
$this->loadEnvironment(); $this->initEnvironment();
} }
/** /**
@ -151,8 +220,8 @@ class Config
*/ */
public function reload() public function reload()
{ {
$this->loadGeneral(); $this->initGeneral();
$this->loadEnvironment(); $this->initEnvironment();
} }
/** /**
@ -280,17 +349,12 @@ class Config
{ {
$hosts = array(); $hosts = array();
if (isset($this->config['environment']['hosts'])) { $envConfig = $this->getEnvironmentConfig();
if (is_array($this->config['environment']['hosts'])) { if (isset($envConfig['hosts'])) {
$hosts = (array) $this->config['environment']['hosts']; if (is_array($envConfig['hosts'])) {
} else if (is_string($this->config['environment']['hosts']) && file_exists($this->config['environment']['hosts']) && is_readable($this->config['environment']['hosts'])) { $hosts = (array) $envConfig['hosts'];
$fileContent = fopen($this->config['environment']['hosts'], 'r'); } else if (is_string($envConfig['hosts']) && file_exists($envConfig['hosts']) && is_readable($envConfig['hosts'])) {
while (($host = fgets($fileContent)) == true) { $hosts = $this->getHostsFromFile($envConfig['hosts']);
$host = trim($host);
if ($host != '') {
$hosts[] = $host;
}
}
} }
} }
@ -373,7 +437,7 @@ class Config
*/ */
public function general($option, $default = false) public function general($option, $default = false)
{ {
$config = $this->config['general']; $config = $this->getGeneralConfig();
if (isset($config[$option])) { if (isset($config[$option])) {
if (is_array($default) && ($config[$option] == '')) { if (is_array($default) && ($config[$option] == '')) {
return $default; return $default;
@ -462,7 +526,8 @@ class Config
*/ */
public function setFrom($from) public function setFrom($from)
{ {
$this->config['environment']['deployment']['from'] = $from; $envConfig = $this->getEnvironmentConfig();
$envConfig['deployment']['from'] = $from;
return $this; return $this;
} }
@ -495,9 +560,9 @@ class Config
* @param mixed $default * @param mixed $default
* @return mixed * @return mixed
*/ */
protected function getEnvironmentOption($option, $default = array()) public function getEnvironmentOption($option, $default = array())
{ {
$config = $this->config['environment']; $config = $this->getEnvironmentConfig();
if (isset($config[$option])) { if (isset($config[$option])) {
return $config[$option]; return $config[$option];
} else { } else {
@ -505,4 +570,66 @@ class Config
} }
} }
/**
* Utility methods. TODO To be extracted into own Class
*/
public function parseConfigFile($filePath)
{
if(!file_exists($filePath))
{
throw new ConfigNotFoundException("Cannot find the file at path $filePath");
}
return $this->parseConfigText(file_get_contents($filePath));
}
public function parseConfigText($input)
{
return Yaml::parse($input);
}
/**
* @return array
*/
protected function getGeneralConfig()
{
return $this->generalConfig;
}
/**
* @return array
*/
protected function getEnvironmentConfig()
{
return $this->environmentConfig;
}
/**
* @param string $filePath
*
* @return array
*/
protected function getHostsFromFile($filePath)
{
$handle = fopen($filePath, 'r');
$hosts = array();
try {
$fileContent = stream_get_contents($handle);
$hosts = json_decode($fileContent);
} catch (Exception $e) {
rewind($handle);
//do it old-style: one host per line
while (($host = stream_get_line($handle, self::HOST_NAME_LENGTH)) !== false) {
$host = trim($host);
if (!empty($host)) {
$hosts[] = $host;
}
}
}
return $hosts;
}
} }

13
Mage/Config/ConfigNotFoundException.php

@ -0,0 +1,13 @@
<?php
namespace Mage\Config;
use Mage\Yaml\Exception\RuntimeException;
/**
*
* @author Vladimir Grigor <vgrigor@gmail.com>
*/
class ConfigNotFoundException extends RuntimeException
{
}

13
Mage/Config/OptionalConfigNotFoundException.php

@ -0,0 +1,13 @@
<?php
namespace Mage\Config;
use Mage\Yaml\Exception\RuntimeException;
/**
*
* @author Vladimir Grigor <vgrigor@gmail.com>
*/
class OptionalConfigNotFoundException extends RuntimeException
{
}

13
Mage/Config/RequiredConfigNotFoundException.php

@ -0,0 +1,13 @@
<?php
namespace Mage\Config;
use Mage\Yaml\Exception\RuntimeException;
/**
*
* @author Vladimir Grigor <vgrigor@gmail.com>
*/
class RequiredConfigNotFoundException extends RuntimeException
{
}

24
Mage/Console.php

@ -24,6 +24,12 @@ use RecursiveDirectoryIterator;
*/ */
class Console class Console
{ {
/**
* TODO refactor into own static class
* @var array
*/
public static $paramsNotRequiringEnvironment = array('install'=>'install', 'upgrade'=>'upgrade', 'version'=>'version');
/** /**
* Handler to the current Log File. * Handler to the current Log File.
* @var mixed * @var mixed
@ -93,16 +99,22 @@ class Console
$commandName = $config->getArgument(0); $commandName = $config->getArgument(0);
// Logging // Logging
$showGrettings = true; $showGreetings = true;
if (in_array($commandName, array('install', 'upgrade', 'version'))) {
if (in_array($commandName, self::$paramsNotRequiringEnvironment)) {
self::$logEnabled = false; self::$logEnabled = false;
$showGrettings = false; $showGreetings = false;
} else { } else {
self::$logEnabled = $config->general('logging', false); self::$logEnabled = $config->general('logging', false);
if(self::$logEnabled)
{
self::log("Logging enabled");
self::output('<red> Logging enabled: ' . self::getLogFile() . '</red>', 1, 1);
}
} }
// Grettings // Greetings
if ($showGrettings) { if ($showGreetings) {
self::output('Starting <blue>Magallanes</blue>', 0, 2); self::output('Starting <blue>Magallanes</blue>', 0, 2);
} }
@ -128,7 +140,7 @@ class Console
} }
} }
if ($showGrettings) { if ($showGreetings) {
self::output('Finished <blue>Magallanes</blue>', 0, 2); self::output('Finished <blue>Magallanes</blue>', 0, 2);
if (file_exists(getcwd() . '/.mage/~working.lock')) { if (file_exists(getcwd() . '/.mage/~working.lock')) {
unlink(getcwd() . '/.mage/~working.lock'); unlink(getcwd() . '/.mage/~working.lock');

10
Mage/Task/AbstractTask.php

@ -150,7 +150,15 @@ abstract class AbstractTask
*/ */
public function getParameter($name, $default = null) public function getParameter($name, $default = null)
{ {
return $this->getConfig()->getParameter($name, $default, $this->parameters); return $this->getConfig()->getParameter($name, $default, $this->getParameters());
}
/**
* @return array
*/
protected function getParameters()
{
return $this->parameters;
} }
/** /**

3
Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php

@ -28,10 +28,11 @@ abstract class BaseStrategyTaskAbstract extends AbstractTask implements IsReleas
protected function checkOverrideRelease() protected function checkOverrideRelease()
{ {
$overrideRelease = $this->getParameter('overrideRelease', false); $overrideRelease = $this->getParameter('overrideRelease', false);
$symlink = $this->getConfig()->release('symlink', 'current');
if ($overrideRelease == true) { if ($overrideRelease == true) {
$releaseToOverride = false; $releaseToOverride = false;
$resultFetch = $this->runCommandRemote('ls -ld current | cut -d"/" -f2', $releaseToOverride); $resultFetch = $this->runCommandRemote('ls -ld '.$symlink.' | cut -d"/" -f2', $releaseToOverride);
if ($resultFetch && is_numeric($releaseToOverride)) { if ($resultFetch && is_numeric($releaseToOverride)) {
$this->getConfig()->setReleaseId($releaseToOverride); $this->getConfig()->setReleaseId($releaseToOverride);
} }

13
Mage/Task/Factory.php

@ -48,22 +48,15 @@ class Factory
$taskName = str_replace(' ', '', $taskName); $taskName = str_replace(' ', '', $taskName);
if (strpos($taskName, '/') === false) { if (strpos($taskName, '/') === false) {
Autoload::loadUserTask($taskName); $className = $taskName;
$className = 'Task\\' . ucfirst($taskName);
} else { } else {
$taskName = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $taskName))); $className = 'Mage\\Task\\BuiltIn\\' . str_replace(' ', '\\', ucwords(str_replace('/', ' ', $taskName))) . 'Task';
$className = 'Mage\\Task\\BuiltIn\\' . $taskName . 'Task';
} }
if (class_exists($className) || Autoload::isLoadable($className)) {
$instance = new $className($taskConfig, $inRollback, $stage, $taskParameters); $instance = new $className($taskConfig, $inRollback, $stage, $taskParameters);
} else {
throw new ErrorWithMessageException('The Task "' . $taskName . '" doesn\'t exists.');
}
if (!($instance instanceOf AbstractTask)) { if (!is_a($instance,'Mage\Task\AbstractTask')) {
throw new Exception('The Task ' . $taskName . ' must be an instance of Mage\Task\AbstractTask.'); throw new Exception('The Task ' . $taskName . ' must be an instance of Mage\Task\AbstractTask.');
} }

5
bin/mage

@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Mage\Autoload;
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
$baseDir = dirname(dirname(__FILE__)); $baseDir = dirname(dirname(__FILE__));
@ -18,7 +20,8 @@ define('MAGALLANES_DIRECTORY', $baseDir);
// Preload // Preload
require_once $baseDir . '/Mage/Autoload.php'; require_once $baseDir . '/Mage/Autoload.php';
spl_autoload_register(array('Mage\\Autoload', 'autoload')); $loader = new Autoload();
spl_autoload_register(array($loader, 'autoLoad'));
// Clean arguments // Clean arguments
array_shift($argv); array_shift($argv);

Loading…
Cancel
Save