X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FCodeGen%2FSpecification.php;h=1818d3c52d32de247dd309e708a1ed7823e7509e;hb=51daafaadd025703b2f8d6e3d27898e3768908f9;hp=c66b91df3e885be02992574e6f412c3d88b6629e;hpb=57d090304a9494de9d1e47b688495f1fff984c1b;p=civicrm-core.git diff --git a/CRM/Core/CodeGen/Specification.php b/CRM/Core/CodeGen/Specification.php index c66b91df3e..1818d3c52d 100644 --- a/CRM/Core/CodeGen/Specification.php +++ b/CRM/Core/CodeGen/Specification.php @@ -12,6 +12,7 @@ class CRM_Core_CodeGen_Specification { /** * Read and parse. * + * @param $schemaPath * @param string $buildVersion which version of the schema to build */ function parse($schemaPath, $buildVersion) { @@ -55,6 +56,11 @@ class CRM_Core_CodeGen_Specification { } } + /** + * @param $dbXML + * + * @return array + */ function &getDatabase(&$dbXML) { $database = array('name' => trim((string ) $dbXML->name)); @@ -74,6 +80,12 @@ class CRM_Core_CodeGen_Specification { return $database; } + /** + * @param $dbXML + * @param $database + * + * @return array + */ function getTables($dbXML, &$database) { $tables = array(); foreach ($dbXML->tables as $tablesXML) { @@ -91,12 +103,21 @@ class CRM_Core_CodeGen_Specification { return $tables; } + /** + * @param $tables + * @param $classNames + */ function resolveForeignKeys(&$tables, &$classNames) { foreach (array_keys($tables) as $name) { $this->resolveForeignKey($tables, $classNames, $name); } } + /** + * @param $tables + * @param $classNames + * @param $name + */ function resolveForeignKey(&$tables, &$classNames, $name) { if (!array_key_exists('foreignKey', $tables[$name])) { return; @@ -114,6 +135,11 @@ class CRM_Core_CodeGen_Specification { } } + /** + * @param $tables + * + * @return array + */ function orderTables(&$tables) { $ordered = array(); @@ -128,6 +154,13 @@ class CRM_Core_CodeGen_Specification { return $ordered; } + /** + * @param $tables + * @param $valid + * @param $name + * + * @return bool + */ function validTable(&$tables, &$valid, $name) { if (!array_key_exists('foreignKey', $tables[$name])) { return TRUE; @@ -142,6 +175,11 @@ class CRM_Core_CodeGen_Specification { return TRUE; } + /** + * @param $tableXML + * @param $database + * @param $tables + */ function getTable($tableXML, &$database, &$tables) { $name = trim((string ) $tableXML->name); $klass = trim((string ) $tableXML->class); @@ -238,6 +276,10 @@ class CRM_Core_CodeGen_Specification { return; } + /** + * @param $fieldXML + * @param $fields + */ function getField(&$fieldXML, &$fields) { $name = trim((string ) $fieldXML->name); $field = array('name' => $name, 'localizable' => $fieldXML->localizable); @@ -372,6 +414,11 @@ class CRM_Core_CodeGen_Specification { $fields[$name] = &$field; } + /** + * @param $name + * + * @return string + */ function composeTitle($name) { $names = explode('_', strtolower($name)); $title = ''; @@ -393,6 +440,11 @@ class CRM_Core_CodeGen_Specification { return trim($title); } + /** + * @param $primaryXML + * @param $fields + * @param $table + */ function getPrimaryKey(&$primaryXML, &$fields, &$table) { $name = trim((string ) $primaryXML->name); @@ -412,6 +464,11 @@ class CRM_Core_CodeGen_Specification { $table['primaryKey'] = &$primaryKey; } + /** + * @param $indexXML + * @param $fields + * @param $indices + */ function getIndex(&$indexXML, &$fields, &$indices) { //echo "\n\n*******************************************************\n"; //echo "entering getIndex\n"; @@ -473,6 +530,12 @@ class CRM_Core_CodeGen_Specification { $indices[$indexName] = &$index; } + /** + * @param $foreignXML + * @param $fields + * @param $foreignKeys + * @param $currentTableName + */ function getForeignKey(&$foreignXML, &$fields, &$foreignKeys, &$currentTableName) { $name = trim((string ) $foreignXML->name); @@ -498,6 +561,10 @@ class CRM_Core_CodeGen_Specification { $foreignKeys[$name] = &$foreignKey; } + /** + * @param $foreignXML + * @param $dynamicForeignKeys + */ function getDynamicForeignKey(&$foreignXML, &$dynamicForeignKeys) { $foreignKey = array( 'idColumn' => trim($foreignXML->idColumn), @@ -507,6 +574,13 @@ class CRM_Core_CodeGen_Specification { $dynamicForeignKeys[] = $foreignKey; } + /** + * @param $key + * @param $object + * @param null $default + * + * @return null|string + */ protected function value($key, &$object, $default = NULL) { if (isset($object->$key)) { return (string ) $object->$key; @@ -514,6 +588,13 @@ class CRM_Core_CodeGen_Specification { return $default; } + /** + * @param $attributes + * @param $object + * @param $name + * @param null $pre + * @param null $post + */ protected function checkAndAppend(&$attributes, &$object, $name, $pre = NULL, $post = NULL) { if (!isset($object->$name)) { return; @@ -523,6 +604,11 @@ class CRM_Core_CodeGen_Specification { $this->append($attributes, ' ', trim($value)); } + /** + * @param $str + * @param $delim + * @param $name + */ protected function append(&$str, $delim, $name) { if (empty($name)) { return;