Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#463 Add in ability for Extensions to use their Extension Utils class to s… #12986

Merged
merged 1 commit into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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