From bf144e748c568012e20bca579d1c742af1a0ef00 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 15 Apr 2019 13:25:52 +1000 Subject: [PATCH] Update dao.tpl to not make presence of import or export required to add 'where' param Import & export have been hopelessly overloaded & misued in the code. One reason is that without them 'where' is not present. Logically import & export should have a narrow usage and should not be a pre-requisite for being available as a search field, in reality not so much. This simply makes the 'where' field available regardless of the presence of these fields By doing this we can make the metadata in the Query object able to handle more fields without special handling (e.g Contribution Recur fields) --- CRM/Core/CodeGen/Util/Template.php | 1 + xml/templates/dao.tpl | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/CRM/Core/CodeGen/Util/Template.php b/CRM/Core/CodeGen/Util/Template.php index 66efbc3867..ed2eac1cae 100644 --- a/CRM/Core/CodeGen/Util/Template.php +++ b/CRM/Core/CodeGen/Util/Template.php @@ -77,6 +77,7 @@ class CRM_Core_CodeGen_Util_Template { "\n }\n}\n" => "\n }\n\n}\n", '=> true,' => '=> TRUE,', '=> false,' => '=> FALSE,', + 'static ::' => 'static::' ]; $contents = str_replace(array_keys($replacements), array_values($replacements), $contents); $contents = preg_replace('#(\s*)\\/\\*\\*#', "\n\$1/**", $contents); diff --git a/xml/templates/dao.tpl b/xml/templates/dao.tpl index 8e0f26f42d..f4e39f4d67 100644 --- a/xml/templates/dao.tpl +++ b/xml/templates/dao.tpl @@ -116,18 +116,15 @@ class {$table.className} extends CRM_Core_DAO {ldelim} {if $field.import} 'import' => {$field.import|strtoupper}, - 'where' => '{$table.name}.{$field.name}', - 'headerPattern' => '{$field.headerPattern}', - 'dataPattern' => '{$field.dataPattern}', + {/if} {* field.import *} + 'where' => '{$table.name}.{$field.name}', + {if $field.headerPattern}'headerPattern' => '{$field.headerPattern}',{/if} + {if $field.dataPattern}'dataPattern' => '{$field.dataPattern}',{/if} {if $field.export} 'export' => {$field.export|strtoupper}, - {if ! $field.import} - 'where' => '{$table.name}.{$field.name}', - 'headerPattern' => '{$field.headerPattern}', - 'dataPattern' => '{$field.dataPattern}', - {/if} {/if} {* field.export *} + {if $field.rule} 'rule' => '{$field.rule}', {/if} {* field.rule *} -- 2.25.1