src/Codegen/CodegenBase.php
public static function run($strSettingsXmlFilePath)
    {
        if (!defined('QCUBED_CODE_GENERATING')) {
            define('QCUBED_CODE_GENERATING', true);
        }

        Codegen::$CodeGenArray = array();
        Codegen::$SettingsFilePath = $strSettingsXmlFilePath;

        if (!file_exists($strSettingsXmlFilePath)) {
            Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
            return;
        }

        if (!is_file($strSettingsXmlFilePath)) {
            Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
            return;
        }

        // Try Parsing the Xml Settings File
        try {
            $errorHandler = new Error\Handler('\\QCubed\\Codegen\\QcubedHandleCodeGenParseError', E_ALL);
            Codegen::$SettingsXml = new \SimpleXMLElement(file_get_contents($strSettingsXmlFilePath));
            $errorHandler->restore();
        } catch (\Exception $objExc) {
            Codegen::$RootErrors .= 'FATAL ERROR: Unable to parse CodeGenSettings XML File: ' . $strSettingsXmlFilePath;
            Codegen::$RootErrors .= "\r\n";
            Codegen::$RootErrors .= $objExc->getMessage();
            return;
        }

        // Application Name
        Codegen::$ApplicationName = Codegen::lookupSetting(Codegen::$SettingsXml, 'name', 'application');

        // Codegen Defaults
        Codegen::$PreferredRenderMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen',
            'preferredRenderMethod');
        Codegen::$CreateMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'createMethod');
        Codegen::$DefaultButtonClass = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'buttonClass');

        if (!Codegen::$DefaultButtonClass) {
            Codegen::$RootErrors .= "CodeGen Settings XML Fatal Error: buttonClass was not defined\r\n";
            return;
        }

        // Iterate Through DataSources
        if (Codegen::$SettingsXml->dataSources->asXML()) {
            foreach (Codegen::$SettingsXml->dataSources->children() as $objChildNode) {
                switch (dom_import_simplexml($objChildNode)->nodeName) {
                    case 'database':
                        Codegen::$CodeGenArray[] = new DatabaseCodeGen($objChildNode);
                        break;
                    case 'restService':
                        Codegen::$CodeGenArray[] = new RestServiceCodeGen($objChildNode);
                        break;
                    default:
                        Codegen::$RootErrors .= sprintf("Invalid Data Source Type in CodeGen Settings XML File (%s): %s\r\n",
                            $strSettingsXmlFilePath, dom_import_simplexml($objChildNode)->nodeName);
                        break;
                }
            }
        }
    }
public static function run($strSettingsXmlFilePath)
    {
        if (!defined('QCUBED_CODE_GENERATING')) {
            define('QCUBED_CODE_GENERATING', true);
        }

        Codegen::$CodeGenArray = array();
        Codegen::$SettingsFilePath = $strSettingsXmlFilePath;

        if (!file_exists($strSettingsXmlFilePath)) {
            Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
            return;
        }

        if (!is_file($strSettingsXmlFilePath)) {
            Codegen::$RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $strSettingsXmlFilePath . ') was not found.';
            return;
        }

        // Try Parsing the Xml Settings File
        try {
            $errorHandler = new Error\Handler('\\QCubed\\Codegen\\QcubedHandleCodeGenParseError', E_ALL);
            Codegen::$SettingsXml = new \SimpleXMLElement(file_get_contents($strSettingsXmlFilePath));
            $errorHandler->restore();
        } catch (\Exception $objExc) {
            Codegen::$RootErrors .= 'FATAL ERROR: Unable to parse CodeGenSettings XML File: ' . $strSettingsXmlFilePath;
            Codegen::$RootErrors .= "\r\n";
            Codegen::$RootErrors .= $objExc->getMessage();
            return;
        }

        // Application Name
        Codegen::$ApplicationName = Codegen::lookupSetting(Codegen::$SettingsXml, 'name', 'application');

        // Codegen Defaults
        Codegen::$PreferredRenderMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen',
            'preferredRenderMethod');
        Codegen::$CreateMethod = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'createMethod');
        Codegen::$DefaultButtonClass = Codegen::lookupSetting(Codegen::$SettingsXml, 'formgen', 'buttonClass');

        if (!Codegen::$DefaultButtonClass) {
            Codegen::$RootErrors .= "CodeGen Settings XML Fatal Error: buttonClass was not defined\r\n";
            return;
        }

        // Iterate Through DataSources
        if (Codegen::$SettingsXml->dataSources->asXML()) {
            foreach (Codegen::$SettingsXml->dataSources->children() as $objChildNode) {
                switch (dom_import_simplexml($objChildNode)->nodeName) {
                    case 'database':
                        Codegen::$CodeGenArray[] = new DatabaseCodeGen($objChildNode);
                        break;
                    case 'restService':
                        Codegen::$CodeGenArray[] = new RestServiceCodeGen($objChildNode);
                        break;
                    default:
                        Codegen::$RootErrors .= sprintf("Invalid Data Source Type in CodeGen Settings XML File (%s): %s\r\n",
                            $strSettingsXmlFilePath, dom_import_simplexml($objChildNode)->nodeName);
                        break;
                }
            }
        }
    }
public static function run ( $ strSettingsXmlFilePath ) { if ( ! defined ( 'QCUBED_CODE_GENERATING' ) ) { define ( 'QCUBED_CODE_GENERATING' , true ) ; } Codegen :: $ CodeGenArray = array ( ) ; Codegen :: $ SettingsFilePath = $ strSettingsXmlFilePath ; if ( ! file_exists ( $ strSettingsXmlFilePath ) ) { Codegen :: $ RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $ strSettingsXmlFilePath . ') was not found.' ; return ; } if ( ! is_file ( $ strSettingsXmlFilePath ) ) { Codegen :: $ RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $ strSettingsXmlFilePath . ') was not found.' ; return ; } // Try Parsing the Xml Settings File try { $ errorHandler = new Error \ Handler ( '\\QCubed\\Codegen\\QcubedHandleCodeGenParseError' , E_ALL ) ; Codegen :: $ SettingsXml = new \ SimpleXMLElement ( file_get_contents ( $ strSettingsXmlFilePath ) ) ; $ errorHandler -> restore ( ) ; } catch ( \ Exception $ objExc ) { Codegen :: $ RootErrors .= 'FATAL ERROR: Unable to parse CodeGenSettings XML File: ' . $ strSettingsXmlFilePath ; Codegen :: $ RootErrors .= "\r\n" ; Codegen :: $ RootErrors .= $ objExc -> getMessage ( ) ; return ; } // Application Name Codegen :: $ ApplicationName = Codegen :: lookupSetting ( Codegen :: $ SettingsXml , 'name' , 'application' ) ; // Codegen Defaults Codegen :: $ PreferredRenderMethod = Codegen :: lookupSetting ( Codegen :: $ SettingsXml , 'formgen' , 'preferredRenderMethod' ) ; Codegen :: $ CreateMethod = Codegen :: lookupSetting ( Codegen :: $ SettingsXml , 'formgen' , 'createMethod' ) ; Codegen :: $ DefaultButtonClass = Codegen :: lookupSetting ( Codegen :: $ SettingsXml , 'formgen' , 'buttonClass' ) ; if ( ! Codegen :: $ DefaultButtonClass ) { Codegen :: $ RootErrors .= "CodeGen Settings XML Fatal Error: buttonClass was not defined\r\n" ; return ; } // Iterate Through DataSources if ( Codegen :: $ SettingsXml -> dataSources -> asXML ( ) ) { foreach ( Codegen :: $ SettingsXml -> dataSources -> children ( ) as $ objChildNode ) { switch ( dom_import_simplexml ( $ objChildNode ) -> nodeName ) { case 'database' : Codegen :: $ CodeGenArray [ ] = new DatabaseCodeGen ( $ objChildNode ) ; break ; case 'restService' : Codegen :: $ CodeGenArray [ ] = new RestServiceCodeGen ( $ objChildNode ) ; break ; default : Codegen :: $ RootErrors .= sprintf ( "Invalid Data Source Type in CodeGen Settings XML File (%s): %s\r\n" , $ strSettingsXmlFilePath , dom_import_simplexml ( $ objChildNode ) -> nodeName ) ; break ; } } } }
The function which actually performs the steps for code generation
Code generation begins here.
@param string $strSettingsXmlFilePath Path to the settings file
The function which actually performs the steps for code generation Code generation begins here .