Skip to content

Commit

Permalink
Merge pull request #12986 from seamuslee001/lab_core_463
Browse files Browse the repository at this point in the history
dev/core#463 Add in ability for Extensions to use their Extension Utils class to s…
  • Loading branch information
seamuslee001 authored Oct 30, 2018
2 parents c2e6acc + 8af97d9 commit 81e3283
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 11 additions & 1 deletion CRM/Core/CodeGen/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,23 @@ class CRM_Core_CodeGen_DAO extends CRM_Core_CodeGen_BaseTask {
*/
private $raw;

/**
* @var string
* translate function name
*/
private $tsFunctionName;

/**
* CRM_Core_CodeGen_DAO constructor.
*
* @param \CRM_Core_CodeGen_Main $config
* @param string $name
* @param string $tsFunctionName
*/
public function __construct($config, $name) {
public function __construct($config, $name, $tsFunctionName = 'ts') {
parent::__construct($config);
$this->name = $name;
$this->tsFunctionName = $tsFunctionName;
}

/**
Expand Down Expand Up @@ -69,6 +77,7 @@ public function run() {
$template->assign('indicesPhp', var_export($this->tables[$this->name]['index'], 1));
}
$template->assign('genCodeChecksum', $this->getTableChecksum());
$template->assign('tsFunctionName', $this->tsFunctionName);
$template->run('dao.tpl', $this->getAbsFileName());
}

Expand All @@ -88,6 +97,7 @@ public function getRaw() {
$template->assign('indicesPhp', var_export($this->tables[$this->name]['index'], 1));
}
$template->assign('genCodeChecksum', 'NEW');
$template->assign('tsFunctionName', $this->tsFunctionName);
$this->raw = $template->fetch('dao.tpl');
}
return $this->raw;
Expand Down
6 changes: 3 additions & 3 deletions xml/templates/dao.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ class {$table.className} extends CRM_Core_DAO {ldelim}
'name' => '{$field.name}',
'type' => {$field.crmType},
{if $field.title}
'title' => ts('{$field.title}'),
'title' => {$tsFunctionName}('{$field.title}'),
{/if}
{if $field.comment}
'description' => ts('{$field.comment|replace:"'":"\'"}'),
'description' => {$tsFunctionName}('{$field.comment|replace:"'":"\'"}'),
{/if}
{if $field.required}
'required' => {$field.required|strtoupper},
Expand Down Expand Up @@ -148,7 +148,7 @@ class {$table.className} extends CRM_Core_DAO {ldelim}
{if $field.html}
'html' => array(
{foreach from=$field.html item=val key=key}
'{$key}' => {if $key eq 'label'}ts("{$val}"){else}'{$val}'{/if},
'{$key}' => {if $key eq 'label'}{$tsFunctionName}("{$val}"){else}'{$val}'{/if},
{/foreach}
),
{/if}
Expand Down

0 comments on commit 81e3283

Please sign in to comment.