Merge pull request #20951 from eileenmcnaughton/act
[civicrm-core.git] / xml / templates / dao.tpl
index 86b7a544cc413d853cd54eb0d742bca0fdee25d9..f80ab793ac146b4e56fc2d560af809657613de6a 100644 (file)
@@ -7,7 +7,7 @@
  * {$generated}
  * (GenCodeChecksum:{$genCodeChecksum})
  */
-{$useHelper}
+{if isset($useHelper)}{$useHelper}{/if}
 /**
  * Database access object for the {$table.entity} entity.
  */
@@ -24,6 +24,16 @@ class {$table.className} extends CRM_Core_DAO {ldelim}
       */
       public static $_tableName = '{$table.name}';
 
+   {* Only print this variable if it's different than the default in CRM_Core_DAO *}
+   {if count($table.primaryKey.field) !== 1 || $table.primaryKey.field.0 !== 'id'}
+     /**
+      * Primary key field(s).
+      *
+      * @var string[]
+      */
+      public static $_primaryKey = [{if $table.primaryKey.field}'{"', '"|implode:$table.primaryKey.field}'{/if}];
+   {/if}
+
    {if $table.icon}
      /**
       * Icon associated with this entity.
@@ -87,6 +97,16 @@ class {$table.className} extends CRM_Core_DAO {ldelim}
         return $plural ? {$tsFunctionName}('{$table.titlePlural}') : {$tsFunctionName}('{$table.title}');
     {rdelim}
 
+{if !empty($table.description)}
+  /**
+  * Returns user-friendly description of this entity.
+  *
+  * @return string
+  */
+  public static function getEntityDescription() {ldelim}
+    return {$tsFunctionName}('{$table.description|replace:"'":"\'"}');
+  {rdelim}
+{/if}
 
 
 {if !empty($table.foreignKey) || !empty($table.dynamicForeignKey)}