* Read and parse.
*
* @param $schemaPath
- * @param string $buildVersion which version of the schema to build
+ * @param string $buildVersion
+ * Which version of the schema to build.
*/
public function parse($schemaPath, $buildVersion) {
$this->buildVersion = $buildVersion;
- echo "Parsing schema description ".$schemaPath."\n";
+ echo "Parsing schema description " . $schemaPath . "\n";
$dbXML = CRM_Core_CodeGen_Util_Xml::parse($schemaPath);
// print_r( $dbXML );
$this->tables = $this->orderTables($this->tables);
// add archive tables here
- $archiveTables = array( );
- foreach ($this->tables as $name => $table ) {
- if ( $table['archive'] == 'true' ) {
+ $archiveTables = array();
+ foreach ($this->tables as $name => $table) {
+ if ($table['archive'] == 'true') {
$name = 'archive_' . $table['name'];
$table['name'] = $name;
$table['archive'] = 'false';
- if ( isset($table['foreignKey']) ) {
+ if (isset($table['foreignKey'])) {
foreach ($table['foreignKey'] as $fkName => $fkValue) {
if ($this->tables[$fkValue['table']]['archive'] == 'true') {
$table['foreignKey'][$fkName]['table'] = 'archive_' . $table['foreignKey'][$fkName]['table'];
$table['foreignKey'][$fkName]['uniqName'] =
- str_replace( 'FK_', 'FK_archive_', $table['foreignKey'][$fkName]['uniqName'] );
+ str_replace('FK_', 'FK_archive_', $table['foreignKey'][$fkName]['uniqName']);
}
}
$archiveTables[$name] = $table;
$field['rows'] = isset($fieldXML->html) ? $this->value('rows', $fieldXML->html) : NULL;
$field['cols'] = isset($fieldXML->html) ? $this->value('cols', $fieldXML->html) : NULL;
break;
- break;
+
+ break;
case 'datetime':
$field['sqlType'] = $field['phpType'] = $type;
);
$field['html'] = array();
foreach ($validOptions as $htmlOption) {
- if(!empty($fieldXML->html->$htmlOption)){
+ if (!empty($fieldXML->html->$htmlOption)) {
$field['html'][$htmlOption] = $this->value($htmlOption, $fieldXML->html);
}
}
}
$field['pseudoconstant'] = $this->value('pseudoconstant', $fieldXML);
- if(!empty($field['pseudoconstant'])){
+ if (!empty($field['pseudoconstant'])) {
//ok this is a bit long-winded but it gets there & is consistent with above approach
$field['pseudoconstant'] = array();
$validOptions = array(
'callback',
);
foreach ($validOptions as $pseudoOption) {
- if(!empty($fieldXML->pseudoconstant->$pseudoOption)){
+ if (!empty($fieldXML->pseudoconstant->$pseudoOption)) {
$field['pseudoconstant'][$pseudoOption] = $this->value($pseudoOption, $fieldXML->pseudoconstant);
}
}
/** need to make sure there is a field of type name */
if (!array_key_exists($name, $fields)) {
- echo "primary key $name in $table->name does not have a field definition, ignoring\n";
+ echo "primary key $name in $table->name does not have a field definition, ignoring\n";
return;
}
$index = array();
// empty index name is fine
- $indexName = trim((string)$indexXML->name);
+ $indexName = trim((string) $indexXML->name);
$index['name'] = $indexName;
$index['field'] = array();
// populate fields
foreach ($indexXML->fieldName as $v) {
- $fieldName = (string)($v);
- $length = (string)($v['length']);
+ $fieldName = (string) ($v);
+ $length = (string) ($v['length']);
if (strlen($length) > 0) {
$fieldName = "$fieldName($length)";
}
/** need to make sure there is a field of type name */
if (!array_key_exists($name, $fields)) {
- echo "foreign $name in $currentTableName does not have a field definition, ignoring\n";
+ echo "foreign $name in $currentTableName does not have a field definition, ignoring\n";
return;
}