Skip to content

Commit

Permalink
CRM_Core_CodeGen_Specification - Allow use from civicrm-setup
Browse files Browse the repository at this point in the history
For civicrm/civicrm-setup#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.
  • Loading branch information
totten committed Feb 15, 2018
1 parent dac3ef1 commit 644ba48
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions CRM/Core/CodeGen/Specification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -231,8 +237,6 @@ public function getTable($tableXML, &$database, &$tables) {
$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) {
Expand Down

0 comments on commit 644ba48

Please sign in to comment.