Skip to content

EspoCRM – Open Source CRM Application

htmlizer: remove cacheId argument

Yurii837fb41453fa
diff --git a/application/Espo/Core/Authentication/TwoFactor/Email/Util.php b/application/Espo/Core/Authentication/TwoFactor/Email/Util.php
index 7986aa8cea..c10805a632 100644
--- a/application/Espo/Core/Authentication/TwoFactor/Email/Util.php
+++ b/application/Espo/Core/Authentication/TwoFactor/Email/Util.php
@@ -282,8 +282,8 @@ class Util
'code' => $code,
];
- $subject = $htmlizer->render($user, $subjectTpl, null, $data, true);
- $body = $htmlizer->render($user, $bodyTpl, null, $data, true);
+ $subject = $htmlizer->render($user, $subjectTpl, $data, true);
+ $body = $htmlizer->render($user, $bodyTpl, $data, true);
$email = $this->emailFactory->create();
diff --git a/application/Espo/Core/Htmlizer/Htmlizer.php b/application/Espo/Core/Htmlizer/Htmlizer.php
index aac97b5bee..b6ec8450e3 100644
--- a/application/Espo/Core/Htmlizer/Htmlizer.php
+++ b/application/Espo/Core/Htmlizer/Htmlizer.php
@@ -93,7 +93,6 @@ class Htmlizer
/**
* Generate an HTML for entity by a given template.
*
- * @param ?string $cacheId @deprecated To be skipped.
* @param ?array<string, mixed> $additionalData Data will be passed to the template.
* @param bool $skipLinks Do not process related records.
* @internal
@@ -101,19 +100,16 @@ class Htmlizer
public function render(
?Entity $entity,
string $template,
- ?string $cacheId = null,
?array $additionalData = null,
bool $skipLinks = false,
- bool $skipInlineAttachmentHandling = false
+ bool $skipInlineAttachmentHandling = false,
): string {
$helpers = $this->getHelpers();
$template = $this->prepare($template, array_keys($helpers));
- $options = new Options(
- helpers: $helpers,
- );
+ $options = new Options(helpers: $helpers);
$renderer = Handlebars::compile($template, $options);
diff --git a/application/Espo/Core/Htmlizer/TemplateRenderer.php b/application/Espo/Core/Htmlizer/TemplateRenderer.php
index fe3634a781..fd96cdbfdc 100644
--- a/application/Espo/Core/Htmlizer/TemplateRenderer.php
+++ b/application/Espo/Core/Htmlizer/TemplateRenderer.php
@@ -144,7 +144,6 @@ class TemplateRenderer
return $htmlizer->render(
$this->entity,
$template,
- null,
$this->data,
$this->skipRelations,
$this->skipInlineAttachmentHandling
diff --git a/application/Espo/Modules/Crm/Business/Event/Invitations.php b/application/Espo/Modules/Crm/Business/Event/Invitations.php
index 39cc3ea151..e5eb7c7d9e 100644
--- a/application/Espo/Modules/Crm/Business/Event/Invitations.php
+++ b/application/Espo/Modules/Crm/Business/Event/Invitations.php
@@ -129,7 +129,6 @@ class Invitations
$subject = $htmlizer->render(
$entity,
$subjectTpl,
- "$type-email-subject-{$entity->getEntityType()}",
$data,
true,
true
@@ -138,7 +137,6 @@ class Invitations
$body = $htmlizer->render(
$entity,
$bodyTpl,
- "$type-email-body-{$entity->getEntityType()}",
$data,
false,
true
diff --git a/application/Espo/Modules/Crm/Tools/Reminder/Sender/EmailReminder.php b/application/Espo/Modules/Crm/Tools/Reminder/Sender/EmailReminder.php
index b65a332efc..3dda987f39 100644
--- a/application/Espo/Modules/Crm/Tools/Reminder/Sender/EmailReminder.php
+++ b/application/Espo/Modules/Crm/Tools/Reminder/Sender/EmailReminder.php
@@ -143,7 +143,6 @@ class EmailReminder
$subject = $htmlizer->render(
$entity,
$subjectTpl,
- 'reminder-email-subject-' . $entityType,
$data,
true
);
@@ -151,7 +150,6 @@ class EmailReminder
$body = $htmlizer->render(
$entity,
$bodyTpl,
- 'reminder-email-body-' . $entityType,
$data,
false
);
diff --git a/application/Espo/Tools/EmailNotification/AssignmentProcessor.php b/application/Espo/Tools/EmailNotification/AssignmentProcessor.php
index 5ca58934bb..857fc0b8a6 100644
--- a/application/Espo/Tools/EmailNotification/AssignmentProcessor.php
+++ b/application/Espo/Tools/EmailNotification/AssignmentProcessor.php
@@ -157,19 +157,17 @@ class AssignmentProcessor
$templateData['entityTypeLowerFirst'] = Util::mbLowerCaseFirst($templateData['entityType']);
$subject = $this->getHtmlizer()->render(
- $entity,
- $subjectTpl,
- 'assignment-email-subject-' . $entity->getEntityType(),
- $templateData,
- true
+ entity: $entity,
+ template: $subjectTpl,
+ additionalData: $templateData,
+ skipLinks: true
);
$body = $this->getHtmlizer()->render(
- $entity,
- $bodyTpl,
- 'assignment-email-body-' . $entity->getEntityType(),
- $templateData,
- true
+ entity: $entity,
+ template: $bodyTpl,
+ additionalData: $templateData,
+ skipLinks: true
);
$email->set([
diff --git a/application/Espo/Tools/EmailNotification/Processor.php b/application/Espo/Tools/EmailNotification/Processor.php
index 966f3e62a8..640f03eb8d 100644
--- a/application/Espo/Tools/EmailNotification/Processor.php
+++ b/application/Espo/Tools/EmailNotification/Processor.php
@@ -336,8 +336,8 @@ class Processor
$subjectTpl = str_replace(["\n", "\r"], '', $subjectTpl);
- $subject = $this->getHtmlizer()->render($note, $subjectTpl, 'mention-email-subject', $data, true);
- $body = $this->getHtmlizer()->render($note, $bodyTpl, 'mention-email-body', $data, true);
+ $subject = $this->getHtmlizer()->render($note, $subjectTpl, $data, true);
+ $body = $this->getHtmlizer()->render($note, $bodyTpl, $data, true);
$email = $this->entityManager->getRDBRepositoryByClass(Email::class)->getNew();
@@ -517,7 +517,6 @@ class Processor
$subject = $this->getHtmlizer()->render(
$note,
$subjectTpl,
- 'note-post-email-subject-' . $parentType,
$data,
true
);
@@ -525,7 +524,6 @@ class Processor
$body = $this->getHtmlizer()->render(
$note,
$bodyTpl,
- 'note-post-email-body-' . $parentType,
$data,
true
);
@@ -537,8 +535,8 @@ class Processor
$subjectTpl = str_replace(["\n", "\r"], '', $subjectTpl);
- $subject = $this->getHtmlizer()->render($note, $subjectTpl, 'note-post-email-subject', $data, true);
- $body = $this->getHtmlizer()->render($note, $bodyTpl, 'note-post-email-body', $data, true);
+ $subject = $this->getHtmlizer()->render($note, $subjectTpl, $data, true);
+ $body = $this->getHtmlizer()->render($note, $bodyTpl, $data, true);
}
/** @var Email $email */
@@ -684,7 +682,6 @@ class Processor
$subject = $this->getHtmlizer()->render(
entity: $note,
template: $subjectTpl,
- cacheId: 'note-status-email-subject',
additionalData: $data,
skipLinks: true,
);
@@ -692,7 +689,6 @@ class Processor
$body = $this->getHtmlizer()->render(
entity: $note,
template: $bodyTpl,
- cacheId: 'note-status-email-body',
additionalData: $data,
skipLinks: true,
);
@@ -818,7 +814,6 @@ class Processor
$subject = $this->getHtmlizer()->render(
$note,
$subjectTpl,
- 'note-email-received-email-subject-' . $parentType,
$data,
true
);
@@ -826,7 +821,6 @@ class Processor
$body = $this->getHtmlizer()->render(
$note,
$bodyTpl,
- 'note-email-received-email-body-' . $parentType,
$data,
true
);
diff --git a/application/Espo/Tools/EmailTemplate/Processor.php b/application/Espo/Tools/EmailTemplate/Processor.php
index 5524beb24e..acde810108 100644
--- a/application/Espo/Tools/EmailTemplate/Processor.php
+++ b/application/Espo/Tools/EmailTemplate/Processor.php
@@ -91,7 +91,7 @@ class Processor
}
if ($handlebarsInBody) {
- $body = $htmlizer->render($parent, $body, null, null, false, true);
+ $body = $htmlizer->render($parent, $body, null, false, true);
}
}
}
diff --git a/application/Espo/Tools/UserSecurity/Password/RecoveryService.php b/application/Espo/Tools/UserSecurity/Password/RecoveryService.php
index c58fd9f2a7..798a33d501 100644
--- a/application/Espo/Tools/UserSecurity/Password/RecoveryService.php
+++ b/application/Espo/Tools/UserSecurity/Password/RecoveryService.php
@@ -435,8 +435,8 @@ class RecoveryService
$htmlizer = $this->htmlizerFactory->create(true);
- $subject = $htmlizer->render($user, $subjectTpl, null, $data, true);
- $body = $htmlizer->render($user, $bodyTpl, null, $data, true);
+ $subject = $htmlizer->render($user, $subjectTpl, $data, true);
+ $body = $htmlizer->render($user, $bodyTpl, $data, true);
$email
->setSubject($subject)
diff --git a/application/Espo/Tools/UserSecurity/Password/Sender.php b/application/Espo/Tools/UserSecurity/Password/Sender.php
index cf007511ba..547ea16bf8 100644
--- a/application/Espo/Tools/UserSecurity/Password/Sender.php
+++ b/application/Espo/Tools/UserSecurity/Password/Sender.php
@@ -80,8 +80,8 @@ class Sender
$htmlizer = $this->htmlizerFactory->createNoAcl();
- $subject = $htmlizer->render($user, $subjectTpl ?? '', null, $data, true);
- $body = $htmlizer->render($user, $bodyTpl ?? '', null, $data, true);
+ $subject = $htmlizer->render($user, $subjectTpl ?? '', $data, true);
+ $body = $htmlizer->render($user, $bodyTpl ?? '', $data, true);
$email
->addToAddress($emailAddress)
@@ -121,8 +121,8 @@ class Sender
$htmlizer = $this->htmlizerFactory->createNoAcl();
- $subject = $htmlizer->render($user, $subjectTpl ?? '', null, $data, true);
- $body = $htmlizer->render($user, $bodyTpl ?? '', null, $data, true);
+ $subject = $htmlizer->render($user, $subjectTpl ?? '', $data, true);
+ $body = $htmlizer->render($user, $bodyTpl ?? '', $data, true);
$email
->setSubject($subject)
diff --git a/tests/unit/Espo/Core/Htmlizer/HtmlizerTest.php b/tests/unit/Espo/Core/Htmlizer/HtmlizerTest.php
index 310f5ffbb4..11b58aa63c 100644
--- a/tests/unit/Espo/Core/Htmlizer/HtmlizerTest.php
+++ b/tests/unit/Espo/Core/Htmlizer/HtmlizerTest.php
@@ -191,7 +191,7 @@ class HtmlizerTest extends TestCase
$template = "{{file name}}";
$entity->set('name', '1');
- $html = $this->htmlizer->render($entity, $template, skipInlineAttachmentHandling: true);
+ $html = $this->htmlizer->render($entity, $template, null, false, skipInlineAttachmentHandling: true);
$this->assertEquals('?entryPoint=attachment&id=1', $html);
$template = "{{#ifEqual name '1'}}hello{{/ifEqual}}";
@@ -224,7 +224,7 @@ class HtmlizerTest extends TestCase
/** @noinspection HtmlUnknownAttribute */
$template = "<ul><li iterate=\"{{items}}\">{{name}}</li></ul><ul><li iterate=\"{{items}}\">{{name}}</li></ul>";
- $html = $this->htmlizer->render(null, $template, null, [
+ $html = $this->htmlizer->render(null, $template, [
'items' => [
['name' => '1'],
['name' => '2'],
@@ -243,7 +243,7 @@ class HtmlizerTest extends TestCase
$template = "<ul><li x-if=\"{{and (equal 1 1) true}}\">1</li><li x-if=\"{{false}}\">2</li>".
"<li x-if=\"{{1}}\">true</li></ul>";
- $html = $this->htmlizer->render(null, $template, null, []);
+ $html = $this->htmlizer->render(null, $template, []);
/** @noinspection HtmlUnknownAttribute */
$expected = "<ul><li>1</li><li>true</li></ul>";