From 644ba48ede2f878567b4bb7b41133fe570f0b92b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 15 Feb 2018 13:11:37 -0800 Subject: [PATCH] CRM_Core_CodeGen_Specification - Allow use from civicrm-setup For https://github.com/civicrm/civicrm-setup/issues/1, this change allows `civicrm-setup` to read the XML metadata in the same way as GenCode -- which helps us to install the current schema without any intermediate files. --- CRM/Core/CodeGen/Specification.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/CRM/Core/CodeGen/Specification.php b/CRM/Core/CodeGen/Specification.php index 63119cf49e..5d06369437 100644 --- a/CRM/Core/CodeGen/Specification.php +++ b/CRM/Core/CodeGen/Specification.php @@ -16,19 +16,25 @@ class CRM_Core_CodeGen_Specification { * @param string $buildVersion * Which version of the schema to build. */ - public function parse($schemaPath, $buildVersion) { + public function parse($schemaPath, $buildVersion, $verbose = TRUE) { $this->buildVersion = $buildVersion; - echo "Parsing schema description " . $schemaPath . "\n"; + if ($verbose) { + echo "Parsing schema description " . $schemaPath . "\n"; + } $dbXML = CRM_Core_CodeGen_Util_Xml::parse($schemaPath); - echo "Extracting database information\n"; + if ($verbose) { + echo "Extracting database information\n"; + } $this->database = &$this->getDatabase($dbXML); $this->classNames = array(); # TODO: peel DAO-specific stuff out of getTables, and spec reading into its own class - echo "Extracting table information\n"; + if ($verbose) { + echo "Extracting table information\n"; + } $this->tables = $this->getTables($dbXML, $this->database); $this->resolveForeignKeys($this->tables, $this->classNames); @@ -231,8 +237,6 @@ class CRM_Core_CodeGen_Specification { $this->getPrimaryKey($tableXML->primaryKey, $fields, $table); } - // some kind of refresh? - CRM_Core_Config::singleton(FALSE); if ($this->value('index', $tableXML)) { $index = array(); foreach ($tableXML->index as $indexXML) { -- 2.25.1