CRM-14241, fixes to entity generation: FK fixes
authorkurund <kurund@civicrm.org>
Fri, 21 Feb 2014 05:07:26 +0000 (10:37 +0530)
committerkurund <kurund@civicrm.org>
Fri, 21 Feb 2014 05:07:26 +0000 (10:37 +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 3b4f4232ee793f6ce2dd3b64a7c6930473fc4f94..5da3fccae81f58557f10be3bc66da1e7b383a158 100644 (file)
@@ -119,6 +119,8 @@ class CRM_Core_CodeGen_EntitySpecification {
       $tables[$name]['fields'][$fkey]['columnType'] = '\\' . $targetEntity;
       $tables[$name]['fields'][$fkey]['columnInfo'] = '@ORM\ManyToOne(targetEntity="' . $targetEntity . '")';
       $tables[$name]['fields'][$fkey]['columnJoin'] = '@ORM\JoinColumns({@ORM\JoinColumn(name="' . $tables[$name]['foreignKey'][$fkey]['name'] . '", referencedColumnName="' . $tables[$name]['foreignKey'][$fkey]['key'] . '")})';
+
+      $tables[$name]['fields'][$fkey]['setFunctionInput'] = "{$tables[$name]['fields'][$fkey]['columnType']} \${$tables[$name]['fields'][$fkey]['propertyName']} = null";
     }
   }
 
@@ -218,6 +220,7 @@ class CRM_Core_CodeGen_EntitySpecification {
       $field['columnType'] = $field['phpType'];
       $field['columnJoin'] = '';
 
+      $field['setFunctionInput'] = $field['propertyName'];
     }
 
     if ($this->value('primaryKey', $tableXML)) {
index 22a3e4fd001762f8ed3545a6d8e7584e05a8f07c..3f7a20a38c11705af48b40ec1754ea459c237eb0 100644 (file)
@@ -80,10 +80,10 @@ class {$table.className} extends \Civi\Core\Entity {ldelim}
   /**
    * Set {$field.propertyName}
    *
-   * @param {$field.phpType} ${$field.propertyName}
+   * @param {$field.columnType} ${$field.propertyName}
    * @return {$table.className}
    */
-  public function set{$field.functionName}(${$field.propertyName}) {ldelim}
+  public function set{$field.functionName}({$field.setFunctionInput}) {ldelim}
     $this->{$field.propertyName} = ${$field.propertyName};
     return $this;
   {rdelim}
@@ -91,7 +91,7 @@ class {$table.className} extends \Civi\Core\Entity {ldelim}
   /**
    * Get {$field.propertyName}
    *
-   * @return string
+   * @return {$field.columnType}
    */
   public function get{$field.functionName}() {ldelim}
     return $this->{$field.propertyName};