CRM-14241, fixes to entity generation
authorkurund <kurund@civicrm.org>
Fri, 21 Feb 2014 04:40:25 +0000 (10:10 +0530)
committerkurund <kurund@civicrm.org>
Fri, 21 Feb 2014 04:40:25 +0000 (10:10 +0530)
----------------------------------------
* CRM-14241: setup new repo for doctrine integration work
  http://issues.civicrm.org/jira/browse/CRM-14241

CRM/Core/CodeGen/EntitySpecification.php
xml/templates/entity.tpl

index b9b1d83095af67c11a5c6c62bcc0a4314a363e7c..3b4f4232ee793f6ce2dd3b64a7c6930473fc4f94 100644 (file)
@@ -108,6 +108,9 @@ class CRM_Core_CodeGen_EntitySpecification {
         echo "$ftable is not a valid foreign key table in $name\n";
         continue;
       }
+
+      $tables[$name]['fields'][$fkey]['propertyName'] = str_replace('Id', '', $tables[$name]['fields'][$fkey]['propertyName']);
+      $tables[$name]['fields'][$fkey]['functionName'] = str_replace('Id', '', $tables[$name]['fields'][$fkey]['functionName']);
       $tables[$name]['foreignKey'][$fkey]['className'] = $classNames[$ftable];
       $tables[$name]['foreignKey'][$fkey]['fileName'] = str_replace('_', '/', $classNames[$ftable]) . '.php';
       $tables[$name]['fields'][$fkey]['FKClassName'] = $classNames[$ftable];
@@ -192,9 +195,10 @@ class CRM_Core_CodeGen_EntitySpecification {
     }
 
     $table['fields'] = &$fields;
-    $table['hasEnum'] = FALSE;
     foreach ($table['fields'] as &$field) {
-      $field['propertyName'] = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $field['name']))));
+      $propertyName = $field['name'];
+      $field['functionName'] = str_replace(' ', '', ucwords(str_replace('_', ' ', $propertyName)));
+      $field['propertyName'] = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $propertyName))));
 
       $field['columnInfo'] = '@ORM\Column(name="' . $field['name'] . '", type="' . $field['phpType'] . '"';
 
@@ -214,13 +218,6 @@ class CRM_Core_CodeGen_EntitySpecification {
       $field['columnType'] = $field['phpType'];
       $field['columnJoin'] = '';
 
-      /*
-       * FIX ME: if needed
-      if ($field['crmType'] == 'CRM_Utils_Type::T_ENUM') {
-        $table['hasEnum'] = TRUE;
-        break;
-      }*/
-
     }
 
     if ($this->value('primaryKey', $tableXML)) {
@@ -244,8 +241,6 @@ class CRM_Core_CodeGen_EntitySpecification {
     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;
         }
@@ -384,6 +379,7 @@ class CRM_Core_CodeGen_EntitySpecification {
       default:
         $field['sqlType'] = $field['phpType'] = $type;
         if ($type == 'int unsigned') {
+          $field['phpType'] = 'integer';
           $field['crmType'] = 'CRM_Utils_Type::T_INT';
         }
         else {
index 5b7b99348fcc376018a4c84bd09331b0902f59ff..22a3e4fd001762f8ed3545a6d8e7584e05a8f07c 100644 (file)
@@ -83,7 +83,7 @@ class {$table.className} extends \Civi\Core\Entity {ldelim}
    * @param {$field.phpType} ${$field.propertyName}
    * @return {$table.className}
    */
-  public function set{$field.propertyName}(${$field.propertyName}) {ldelim}
+  public function set{$field.functionName}(${$field.propertyName}) {ldelim}
     $this->{$field.propertyName} = ${$field.propertyName};
     return $this;
   {rdelim}
@@ -93,7 +93,7 @@ class {$table.className} extends \Civi\Core\Entity {ldelim}
    *
    * @return string
    */
-  public function get{$field.propertyName}() {ldelim}
+  public function get{$field.functionName}() {ldelim}
     return $this->{$field.propertyName};
   {rdelim}
 {/foreach}