Skip to content

Commit

Permalink
Update dao.tpl to not make presence of import or export required to a…
Browse files Browse the repository at this point in the history
…dd '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)
  • Loading branch information
eileenmcnaughton committed Apr 16, 2019
1 parent ff2c446 commit bf144e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions CRM/Core/CodeGen/Util/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function run($infile, $outpath) {
"\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);
Expand Down
13 changes: 5 additions & 8 deletions xml/templates/dao.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 *}
Expand Down

0 comments on commit bf144e7

Please sign in to comment.