Skip to content

EspoCRM – Open Source CRM Application

leadCaptureSiteUrl

Yuri Kuznetsovb57cfe597f48
diff --git a/application/Espo/Classes/FieldProcessing/LeadCapture/ExampleLoader.php b/application/Espo/Classes/FieldProcessing/LeadCapture/ExampleLoader.php
index b9ce060dec..98616a7041 100644
--- a/application/Espo/Classes/FieldProcessing/LeadCapture/ExampleLoader.php
+++ b/application/Espo/Classes/FieldProcessing/LeadCapture/ExampleLoader.php
@@ -31,6 +31,7 @@ namespace Espo\Classes\FieldProcessing\LeadCapture;
use Espo\Core\FieldProcessing\Loader;
use Espo\Core\FieldProcessing\Loader\Params;
+use Espo\Core\Utils\Config;
use Espo\Core\Utils\Config\ApplicationConfig;
use Espo\Core\Utils\FieldUtil;
use Espo\Core\Utils\Util;
@@ -48,7 +49,8 @@ class ExampleLoader implements Loader
public function __construct(
private FieldUtil $fieldUtil,
private ApplicationConfig $applicationConfig,
- private EntityManager $entityManager
+ private EntityManager $entityManager,
+ private Config $config,
) {}
public function process(Entity $entity, Params $params): void
@@ -136,7 +138,7 @@ class ExampleLoader implements Loader
private function processFormUrl(LeadCapture $entity): void
{
$formId = $entity->getFormId();
- $siteUrl = $this->applicationConfig->getSiteUrl();
+ $siteUrl = $this->getSiteUrl();
if (!$entity->hasFormEnabled() || !$formId) {
/** @noinspection PhpRedundantOptionalArgumentInspection */
@@ -149,4 +151,9 @@ class ExampleLoader implements Loader
$entity->set('formUrl', $formUrl);
}
+
+ private function getSiteUrl(): string
+ {
+ return $this->config->get('leadCaptureSiteUrl') ?? $this->applicationConfig->getSiteUrl();
+ }
}
diff --git a/application/Espo/Resources/defaults/systemConfig.php b/application/Espo/Resources/defaults/systemConfig.php
index adfac81774..b63b9fd187 100644
--- a/application/Espo/Resources/defaults/systemConfig.php
+++ b/application/Espo/Resources/defaults/systemConfig.php
@@ -189,6 +189,7 @@ return [
'adminNotificationsCronIsNotConfigured',
'adminNotificationsNewExtensionVersion',
'leadCaptureAllowOrigin',
+ 'leadCaptureSiteUrl',
'cronDisabled',
'defaultPortalId',
'cleanupDeletedRecords',
diff --git a/application/Espo/Tools/LeadCapture/ConfirmationSender.php b/application/Espo/Tools/LeadCapture/ConfirmationSender.php
index f46a811221..d2c601af4d 100644
--- a/application/Espo/Tools/LeadCapture/ConfirmationSender.php
+++ b/application/Espo/Tools/LeadCapture/ConfirmationSender.php
@@ -35,6 +35,7 @@ use Espo\Core\Mail\EmailSender;
use Espo\Core\Mail\Exceptions\NoSmtp;
use Espo\Core\Mail\Exceptions\SendingError;
use Espo\Core\Templates\Entities\Person;
+use Espo\Core\Utils\Config;
use Espo\Core\Utils\Config\ApplicationConfig;
use Espo\Core\Utils\DateTime;
use Espo\Core\Utils\Language;
@@ -59,6 +60,7 @@ class ConfirmationSender
private DateTime $dateTime,
private EmailTemplateProcessor $emailTemplateProcessor,
private ApplicationConfig $appConfig,
+ private Config $config,
) {}
/**
@@ -166,7 +168,7 @@ class ConfirmationSender
}
}
- $url = $this->appConfig->getSiteUrl() . '/?entryPoint=confirmOptIn&id=' . $uniqueId->getIdValue();
+ $url = $this->getSiteUrl() . '/?entryPoint=confirmOptIn&id=' . $uniqueId->getIdValue();
$linkHtml =
'<a href='.$url.'>' .
@@ -222,4 +224,9 @@ class ConfirmationSender
->withAttachments($emailData->getAttachmentList())
->send($email);
}
+
+ private function getSiteUrl(): string
+ {
+ return $this->config->get('leadCaptureSiteUrl') ?? $this->appConfig->getSiteUrl();
+ }
}