mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 09:00:18 +01:00 
			
		
		
		
	ADVICE: there is no Backwards Compatibility with custom tasks, those using the _config instance will be broken or those using the getEnvironmentName().
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
class Mage_Command_Factory
 | 
						|
{
 | 
						|
    /**
 | 
						|
     *
 | 
						|
     *
 | 
						|
     * @param string $commandName
 | 
						|
     * @param Mage_Config $config
 | 
						|
     * @return Mage_Command_CommandAbstract
 | 
						|
     */
 | 
						|
    public static function get($commandName, Mage_Config $config)
 | 
						|
    {
 | 
						|
        $instance = null;
 | 
						|
        $commandName = ucwords(str_replace('-', ' ', $commandName));
 | 
						|
        $commandName = str_replace(' ', '', $commandName);
 | 
						|
 | 
						|
//        if (strpos($commandName, '/') === false) {
 | 
						|
//            Mage_Autoload::loadUserTask($taskName);
 | 
						|
//            $className = 'Task_' . ucfirst($taskName);
 | 
						|
//            $instance = new $className($taskConfig, $inRollback, $stage);
 | 
						|
 | 
						|
//        } else {
 | 
						|
            $commandName = str_replace(' ', '_', ucwords(str_replace('/', ' ', $commandName)));
 | 
						|
            $className = 'Mage_Command_BuiltIn_' . $commandName;
 | 
						|
            if (Mage_Autoload::isLoadable($className)) {
 | 
						|
                $instance = new $className;
 | 
						|
                $instance->setConfig($config);
 | 
						|
            } else {
 | 
						|
                throw new Exception('Command not found.');
 | 
						|
            }
 | 
						|
 | 
						|
//        }
 | 
						|
 | 
						|
        assert($instance instanceOf Mage_Command_CommandAbstract);
 | 
						|
        return $instance;
 | 
						|
    }
 | 
						|
} |