CoreDAOCodePath = $CoreDAOCodePath; $this->sqlCodePath = $sqlCodePath; $this->phpCodePath = $phpCodePath; $this->tplCodePath = $tplCodePath; $this->digestPath = $digestPath; $this->sourceDigest = NULL; // default cms is 'drupal', if not specified $this->cms = isset($argCms) ? strtolower($argCms) : 'drupal'; $versionFile = $this->phpCodePath . "/xml/version.xml"; $versionXML = CRM_Core_CodeGen_Util_Xml::parse($versionFile); $this->db_version = $versionXML->version_no; $this->buildVersion = preg_replace('/^(\d{1,2}\.\d{1,2})\.(\d{1,2}|\w{4,7})$/i', '$1', $this->db_version); if (isset($argVersion)) { // change the version to that explicitly passed, if any $this->db_version = $argVersion; } $this->schemaPath = $schemaPath; } /** * Automatically generate a variety of files. */ public function main() { echo "\ncivicrm_domain.version := " . $this->db_version . "\n\n"; if ($this->buildVersion < 1.1) { echo "The Database is not compatible for this version"; exit(); } if (substr(phpversion(), 0, 1) < 5) { echo phpversion() . ', ' . substr(phpversion(), 0, 1) . "\n"; echo " CiviCRM requires a PHP Version >= 5 Please upgrade your php / webserver configuration Alternatively you can get a version of CiviCRM that matches your PHP version "; exit(); } foreach ($this->getTasks() as $task) { if (getenv('GENCODE_FORCE') || $task->needsUpdate()) { $task->run(); } } } /** * @return array * Array. * @throws \Exception */ public function getTasks() { $this->init(); $tasks = []; $tasks[] = new CRM_Core_CodeGen_Config($this); $tasks[] = new CRM_Core_CodeGen_Reflection($this); $tasks[] = new CRM_Core_CodeGen_Schema($this); foreach (array_keys($this->tables) as $name) { $tasks[] = new CRM_Core_CodeGen_DAO($this, $name); } $tasks[] = new CRM_Core_CodeGen_I18n($this); return $tasks; } /** * Compute a digest based on the GenCode logic (PHP/tpl). * * @return string */ public function getSourceDigest() { if ($this->sourceDigest === NULL) { $srcDir = CRM_Core_CodeGen_Util_File::findCoreSourceDir(); $files = CRM_Core_CodeGen_Util_File::findManyFiles([ ["$srcDir/CRM/Core/CodeGen", '*.php'], ["$srcDir/xml", "*.php"], ["$srcDir/xml", "*.tpl"], ]); $this->sourceDigest = CRM_Core_CodeGen_Util_File::digestAll($files); } return $this->sourceDigest; } protected function init() { if (!$this->database || !$this->tables) { $specification = new CRM_Core_CodeGen_Specification(); $specification->parse($this->schemaPath, $this->buildVersion); # cheese: $this->database = $specification->database; $this->tables = $specification->tables; } } }