* {$generated}
* (GenCodeChecksum:{$genCodeChecksum})
*/
-{$useHelper}
+{if isset($useHelper)}{$useHelper}{/if}
/**
* Database access object for the {$table.entity} entity.
*/
*/
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.
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 $table.foreignKey || $table.dynamicForeignKey}
+{if !empty($table.foreignKey) || !empty($table.dynamicForeignKey)}
/**
* Returns foreign keys and entity references.
*
public static function getReferenceColumns() {ldelim}
if (!isset(Civi::$statics[__CLASS__]['links'])) {ldelim}
Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
+{if isset($table.foreignKey)}
{foreach from=$table.foreignKey item=foreign}
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), '{$foreign.name}', '{$foreign.table}', '{$foreign.key}');
{/foreach}
-
+{/if}
+{if isset($table.dynamicForeignKey)}
{foreach from=$table.dynamicForeignKey item=foreign}
Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), '{$foreign.idColumn}', NULL, '{$foreign.key|default:'id'}', '{$foreign.typeColumn}');
{/foreach}
+{/if}
CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
{rdelim}
return Civi::$statics[__CLASS__]['links'];
{if $field.required}
'required' => {$field.required|strtoupper},
{/if} {* field.required *}
-{if $field.length}
+{if isset($field.length)}
'maxlength' => {$field.length},
{/if} {* field.length *}
-{if $field.precision}
+{if isset($field.precision)}
'precision' => array({$field.precision}),
{/if}
-{if $field.size}
+{if isset($field.size)}
'size' => {$field.size},
{/if} {* field.size *}
-{if $field.rows}
+{if isset($field.rows)}
'rows' => {$field.rows},
{/if} {* field.rows *}
-{if $field.cols}
+{if isset($field.cols)}
'cols' => {$field.cols},
{/if} {* field.cols *}
'entity' => '{$table.entity}',
'bao' => '{$table.bao}',
'localizable' => {if $field.localizable}1{else}0{/if},
- {if $field.localize_context}'localize_context' => '{$field.localize_context}',{/if}
+ {if isset($field.localize_context)}'localize_context' => '{$field.localize_context}',{/if}
-{if $field.FKClassName}
+{if isset($field.FKClassName)}
'FKClassName' => '{$field.FKClassName}',
{/if}
{if !empty($field.component)}
*/
public static function &import( $prefix = FALSE ) {ldelim}
$r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, '{$table.labelName}', $prefix, array(
- {if $table.foreignKey}{foreach from=$table.foreignKey item=foreign}
+ {if isset($table.foreignKey)}{foreach from=$table.foreignKey item=foreign}
{if $foreign.import}'{$foreign.className}',{/if}
{/foreach}{/if}
));
*/
public static function &export( $prefix = FALSE ) {ldelim}
$r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, '{$table.labelName}', $prefix, array(
- {if $table.foreignKey}{foreach from=$table.foreignKey item=foreign}
+ {if isset($table.foreignKey)}{foreach from=$table.foreignKey item=foreign}
{if $foreign.export}'{$foreign.className}',{/if}
{/foreach}{/if}
));