mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 09:00:18 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
/*
 | 
						|
 * This file is part of the Magallanes package.
 | 
						|
*
 | 
						|
* (c) Andrés Montañez <andres@andresmontanez.com>
 | 
						|
*
 | 
						|
* For the full copyright and license information, please view the LICENSE
 | 
						|
* file that was distributed with this source code.
 | 
						|
*/
 | 
						|
 | 
						|
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;
 | 
						|
    }
 | 
						|
} |