/**
  * Construct the QCodeGen object.
  * 
  * Gives you an opportunity to read your xml file and make codegen changes accordingly.
  */
 public function __construct($objSettingsXml)
 {
     // Specify the paths to your template files here. These paths will be searched in the order declared, to
     // find a particular template file. Template files found lower down in the order will override the previous ones.
     static::$TemplatePaths = array(__QCUBED_CORE__ . '/codegen/templates/', __QCUBED__ . '/codegen/templates/');
 }
 /**
  * Given a template prefix (e.g. db_orm_, db_type_, rest_, soap_, etc.), pull
  * all the _*.tpl templates from any subfolders of the template prefix
  * in QCodeGen::TemplatesPath and QCodeGen::TemplatesPathCustom,
  * and call GenerateFile() on each one.  If there are any template files that reside
  * in BOTH TemplatesPath AND TemplatesPathCustom, then only use the TemplatesPathCustom one (which
  * in essence overrides the one in TemplatesPath)
  *
  * @param string  $strTemplatePrefix the prefix of the templates you want to generate against
  * @param mixed[] $mixArgumentArray  array of arguments to send to EvaluateTemplate
  *
  * @throws Exception
  * @throws QCallerException
  * @return boolean success/failure on whether or not all the files generated successfully
  */
 public function GenerateFiles($strTemplatePrefix, $mixArgumentArray)
 {
     // If you are editing core templates, and getting EOF errors only on the travis build, this may be your problem. Scan your files and remove short tags.
     if (QCodeGen::DebugMode && ini_get('short_open_tag')) {
         _p("Warning: PHP directive short_open_tag is on. Using short tags will cause unexpected EOF on travis build.\n", false);
     }
     // Default the template paths
     if (!static::$TemplatePaths) {
         static::$TemplatePaths = array(__QCUBED_CORE__ . '/codegen/templates/', __QCUBED__ . '/codegen/templates/');
     }
     // validate the template paths
     foreach (static::$TemplatePaths as $strPath) {
         if (!is_dir($strPath)) {
             throw new Exception(sprintf("Template path: %s does not appear to be a valid directory.", $strPath));
         }
     }
     // Create an array of arrays of standard templates and custom (override) templates to process
     // Index by [module_name][filename] => true/false where
     // module name (e.g. "class_gen", "form_delegates) is name of folder within the prefix (e.g. "db_orm")
     // filename is the template filename itself (in a _*.tpl format)
     // true = override (use custom) and false = do not override (use standard)
     $strTemplateArray = array();
     // Go through standard templates first, then override in order
     foreach (static::$TemplatePaths as $strPath) {
         $this->buildTemplateArray($strPath . $strTemplatePrefix, $strTemplateArray);
     }
     // Finally, iterate through all the TemplateFiles and call GenerateFile to Evaluate/Generate/Save them
     $blnSuccess = true;
     foreach ($strTemplateArray as $strModuleName => $strFileArray) {
         foreach ($strFileArray as $strFilename => $strPath) {
             if (!$this->GenerateFile($strTemplatePrefix . '/' . $strModuleName, $strPath, $mixArgumentArray)) {
                 $blnSuccess = false;
             }
         }
     }
     return $blnSuccess;
 }