public function CertificateTemplate::renderView in Certificate 4.x
Return a token replaced certificate HTML.
Parameters
AccountInterface $account: The account to build a certificate for.
ContentEntityBase $entity: The certifiable entity.
Return value
string
File
- src/
Entity/ CertificateTemplate.php, line 145
Class
- CertificateTemplate
- Defines the Certificate Template entity class.
Namespace
Drupal\certificate\EntityCode
public function renderView(AccountInterface $account, $entity) {
if (!$entity instanceof ContentEntityBase) {
return FALSE;
}
$render = $this
->entityTypeManager()
->getViewBuilder('certificate_template')
->view($this
->load($this
->id()));
$opts = [
'user' => $account,
$entity
->getEntityTypeId() => $entity,
];
$renderer = \Drupal::service('renderer');
$text = $renderer
->render($render);
$out = \Drupal::token()
->replace($text, $opts, [
'clear' => TRUE,
'sanitize' => FALSE,
]);
return $out;
}