From 587261c312214bd2d3afca83134f1acee3977d74 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 29 Dec 2021 21:25:21 -0600 Subject: [PATCH] GenCode - Allow overriding the short entity name Before ------ The short entity-name must always be an exact match to the _last_ part of the class-name. Ex: The class `CRM_Mailing_Event_BAO_Queue` has short entity-name of `Queue`. This will cause a conflict if any other subsystem has a class ending in `Queue` (eg `CRM_Contribute_BAO_Queue` or `CRM_Queue_Queue`). After ----- By default, the short entity-name matches the last part of the class-name. But this can be overridden in `xml/schema/*`, eg ```xml CRM/Mailing/EventQueueMailingEventQueue ``` Comments --------- To see that this change is generally safe (ie does not impact existing entity), I force-regenereated all DAOs ``` GENCODE_FORCE=1 ./bin/setup.sh -g ``` This produced no substantive change in existing DAOs -- because they do not have the `` tag. --- CRM/Core/CodeGen/Specification.php | 2 +- xml/templates/listAll.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Core/CodeGen/Specification.php b/CRM/Core/CodeGen/Specification.php index 30bec91f67..3e506184fb 100644 --- a/CRM/Core/CodeGen/Specification.php +++ b/CRM/Core/CodeGen/Specification.php @@ -222,7 +222,7 @@ class CRM_Core_CodeGen_Specification { 'labelName' => substr($name, 8), 'className' => $this->classNames[$name], 'bao' => ($useBao ? str_replace('DAO', 'BAO', $this->classNames[$name]) : $this->classNames[$name]), - 'entity' => $klass, + 'entity' => $tableXML->entity ?? $klass, 'attributes_simple' => trim($database['tableAttributes_simple']), 'attributes_modern' => trim($database['tableAttributes_modern']), 'comment' => $this->value('comment', $tableXML), diff --git a/xml/templates/listAll.tpl b/xml/templates/listAll.tpl index 33fa586a0e..182f53f121 100644 --- a/xml/templates/listAll.tpl +++ b/xml/templates/listAll.tpl @@ -4,7 +4,7 @@ return [ {foreach from=$tables key=tableName item=table} '{$table.className}' => [ - 'name' => '{$table.objectName}', + 'name' => '{$table.entity}', 'class' => '{$table.className}', 'table' => '{$tableName}', ], -- 2.25.1