diff options
Diffstat (limited to 'framework/prado-cli.php')
-rwxr-xr-x | framework/prado-cli.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/framework/prado-cli.php b/framework/prado-cli.php index 9b9153c3..f9185e6b 100755 --- a/framework/prado-cli.php +++ b/framework/prado-cli.php @@ -43,6 +43,7 @@ PradoCommandLineInterpreter::getInstance()->addActionClass('PradoCommandLineCrea PradoCommandLineInterpreter::getInstance()->addActionClass('PradoCommandLinePhpShell'); PradoCommandLineInterpreter::getInstance()->addActionClass('PradoCommandLineUnitTest'); PradoCommandLineInterpreter::getInstance()->addActionClass('PradoCommandLineActiveRecordGen'); +PradoCommandLineInterpreter::getInstance()->addActionClass('PradoCommandLineConvertConfig'); //run it; PradoCommandLineInterpreter::getInstance()->run($_SERVER['argv']); @@ -730,6 +731,58 @@ EOD; } } +/** + * Convert prado 3.1 XML configuration to new prado 3.2 PHP array configuration + * + * @author Christophe Boulain <Christophe Boulain@gmail.com> + * @version $Id$ + * @since 3.2 + */ +class PradoCommandLineConvertConfig extends PradoCommandLineAction +{ + + protected $action = 'xmltophp'; + protected $parameters = array('xml'); + protected $optional = array('output'); + protected $description = 'Convert a prado xml configuration file (<xml>) to a php array. '; + + public function performAction($args) + { + $xml=realpath($args[1]); + if (!is_file($xml)) + { + echo "Unable to find {$args[1]} file.\n"; + return true; + } + $output=$args[2]; + if ($output===null) + $output=dirname($xml).DIRECTORY_SEPARATOR.basename($xml, 'xml')."php"; + if (!is_writable(realpath(dirname($output)))) + { + echo "Can't write new config file {$output}\n"; + return true; + } + $config=$this->parseXML($xml); + print_r($config); + + return true; + } + + /** + * Open and parse an xml config file. + * @param string $xml the filepath of xml file + * @return array + */ + protected function parseXML($xml) + { + $dom=new DOMDocument(); + $dom->load($xml); + print_r ($dom->childNodes); + return ; + } + +} + //run PHP shell if(class_exists('PHP_Shell_Commands', false)) { |