* @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);
$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) {
$this->getIndex($indexXML, $fields, $index);
}
+ CRM_Core_BAO_SchemaHandler::addIndexSignature($name, $index);
$table['index'] = &$index;
}
if ($this->value('foreignKey', $tableXML)) {
$foreign = array();
foreach ($tableXML->foreignKey as $foreignXML) {
- // print_r($foreignXML);
if ($this->value('drop', $foreignXML, 0) > 0 and $this->value('drop', $foreignXML, 0) <= $this->buildVersion) {
continue;
*/
public function getField(&$fieldXML, &$fields) {
$name = trim((string ) $fieldXML->name);
- $field = array('name' => $name, 'localizable' => $fieldXML->localizable);
+ $field = array('name' => $name, 'localizable' => ((bool) $fieldXML->localizable) ? 1 : 0);
$type = (string ) $fieldXML->type;
switch ($type) {
case 'varchar':
$field['headerPattern'] = $this->value('headerPattern', $fieldXML);
$field['dataPattern'] = $this->value('dataPattern', $fieldXML);
$field['uniqueName'] = $this->value('uniqueName', $fieldXML);
+ $field['serialize'] = $this->value('serialize', $fieldXML);
$field['html'] = $this->value('html', $fieldXML);
if (!empty($field['html'])) {
$validOptions = array(
$index['unique'] = TRUE;
}
- //echo "\$index = \n";
- //print_r($index);
-
// field array cannot be empty
if (empty($index['field'])) {
echo "No fields defined for index $indexName\n";