From a27283c4998b92c9d15c557a327c880bf22ffa37 Mon Sep 17 00:00:00 2001 From: kurund Date: Fri, 21 Feb 2014 10:37:26 +0530 Subject: [PATCH] CRM-14241, fixes to entity generation: FK fixes ---------------------------------------- * CRM-14241: setup new repo for doctrine integration work http://issues.civicrm.org/jira/browse/CRM-14241 --- CRM/Core/CodeGen/EntitySpecification.php | 3 +++ xml/templates/entity.tpl | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CRM/Core/CodeGen/EntitySpecification.php b/CRM/Core/CodeGen/EntitySpecification.php index 3b4f4232ee..5da3fccae8 100644 --- a/CRM/Core/CodeGen/EntitySpecification.php +++ b/CRM/Core/CodeGen/EntitySpecification.php @@ -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)) { diff --git a/xml/templates/entity.tpl b/xml/templates/entity.tpl index 22a3e4fd00..3f7a20a38c 100644 --- a/xml/templates/entity.tpl +++ b/xml/templates/entity.tpl @@ -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}; -- 2.25.1