application config
This commit is contained in:
@@ -31,7 +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;
|
||||
use Espo\Entities\LeadCapture;
|
||||
@@ -47,7 +47,7 @@ class ExampleLoader implements Loader
|
||||
{
|
||||
public function __construct(
|
||||
private FieldUtil $fieldUtil,
|
||||
private Config $config,
|
||||
private ApplicationConfig $applicationConfig,
|
||||
private EntityManager $entityManager
|
||||
) {}
|
||||
|
||||
@@ -67,7 +67,7 @@ class ExampleLoader implements Loader
|
||||
private function processRequestUrl(LeadCapture $entity): void
|
||||
{
|
||||
$apiKey = $entity->getApiKey();
|
||||
$siteUrl = $this->config->get('siteUrl');
|
||||
$siteUrl = $this->applicationConfig->getSiteUrl();
|
||||
|
||||
if (!$apiKey) {
|
||||
return;
|
||||
@@ -136,7 +136,7 @@ class ExampleLoader implements Loader
|
||||
private function processFormUrl(LeadCapture $entity): void
|
||||
{
|
||||
$formId = $entity->getFormId();
|
||||
$siteUrl = $this->config->getSiteUrl();
|
||||
$siteUrl = $this->applicationConfig->getSiteUrl();
|
||||
|
||||
if (!$entity->hasFormEnabled() || !$formId) {
|
||||
/** @noinspection PhpRedundantOptionalArgumentInspection */
|
||||
|
||||
@@ -40,16 +40,11 @@ use DateTimeZone;
|
||||
|
||||
class CheckNewVersion implements JobDataLess
|
||||
{
|
||||
/** @var Config */
|
||||
protected $config;
|
||||
/** @var EntityManager */
|
||||
protected $entityManager;
|
||||
|
||||
public function __construct(Config $config, EntityManager $entityManager)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
public function __construct(
|
||||
protected Config $config,
|
||||
protected EntityManager $entityManager,
|
||||
private Config\ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
@@ -78,11 +73,7 @@ class CheckNewVersion implements JobDataLess
|
||||
$nextDay = new DateTime('+ 1 day');
|
||||
$time = $nextDay->format(DateTimeUtil::SYSTEM_DATE_FORMAT) . ' ' . $hour . ':' . $minute . ':00';
|
||||
|
||||
$timeZone = $this->config->get('timeZone');
|
||||
|
||||
if (empty($timeZone)) {
|
||||
$timeZone = 'UTC';
|
||||
}
|
||||
$timeZone = $this->applicationConfig->getTimeZone();
|
||||
|
||||
$datetime = new DateTime($time, new DateTimeZone($timeZone));
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ class SendScheduledEmails implements JobDataLess
|
||||
private SendService $sendService,
|
||||
private Language $language,
|
||||
private AclManager $aclManager,
|
||||
private Config\ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
public function run(): void
|
||||
@@ -136,7 +137,7 @@ class SendScheduledEmails implements JobDataLess
|
||||
|
||||
private function getEmailLink(Email $email): string
|
||||
{
|
||||
return rtrim($this->config->getSiteUrl()) . '#Email/view/' . $email->getId();
|
||||
return rtrim($this->applicationConfig->getSiteUrl()) . '#Email/view/' . $email->getId();
|
||||
}
|
||||
|
||||
private function getUser(Email $email): User
|
||||
|
||||
@@ -33,7 +33,7 @@ use DateTimeZone;
|
||||
use Espo\Core\Field\DateTime;
|
||||
use Espo\Core\Formula\EvaluatedArgumentList;
|
||||
use Espo\Core\Formula\Func;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\ApplicationConfig;
|
||||
use Espo\Core\Utils\DateTime as DateTimeUtil;
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
@@ -44,17 +44,15 @@ use RuntimeException;
|
||||
class TodayType implements Func
|
||||
{
|
||||
public function __construct(
|
||||
private Config $config
|
||||
private ApplicationConfig $applicationConfig
|
||||
) {}
|
||||
|
||||
public function process(EvaluatedArgumentList $arguments): string
|
||||
{
|
||||
/** @var string $timezone */
|
||||
$timezone = $this->config->get('timeZone') ?? 'UTC';
|
||||
$timezone = $this->applicationConfig->getTimeZone();
|
||||
|
||||
try {
|
||||
$today = DateTime::createNow()
|
||||
->withTimezone(new DateTimeZone($timezone));
|
||||
$today = DateTime::createNow()->withTimezone(new DateTimeZone($timezone));
|
||||
} catch (Exception $e) {
|
||||
throw new RuntimeException($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -35,7 +35,10 @@ class ConfigDataProvider
|
||||
{
|
||||
private const MAX_PORTION = 15;
|
||||
|
||||
public function __construct(private Config $config) {}
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
private Config\ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
public function runInParallel(): bool
|
||||
{
|
||||
@@ -63,6 +66,6 @@ class ConfigDataProvider
|
||||
return 'UTC';
|
||||
}
|
||||
|
||||
return $this->config->get('timeZone') ?? 'UTC';
|
||||
return $this->applicationConfig->getTimeZone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,17 +29,17 @@
|
||||
|
||||
namespace Espo\Core\Select\Helpers;
|
||||
|
||||
use Espo\Core\Utils\Config\ApplicationConfig;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\EntityManager;
|
||||
use Espo\Entities\Preferences;
|
||||
use Espo\Core\Utils\Config;
|
||||
|
||||
class UserTimeZoneProvider
|
||||
{
|
||||
public function __construct(
|
||||
private User $user,
|
||||
private EntityManager $entityManager,
|
||||
private Config $config
|
||||
private ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
public function get(): string
|
||||
@@ -51,7 +51,7 @@ class UserTimeZoneProvider
|
||||
}
|
||||
|
||||
if ($preferences->get('timeZone') === null || $preferences->get('timeZone') === '') {
|
||||
return $this->config->get('timeZone');
|
||||
return $this->applicationConfig->getTimeZone();
|
||||
}
|
||||
|
||||
return $preferences->get('timeZone');
|
||||
|
||||
@@ -42,8 +42,10 @@ use RuntimeException;
|
||||
|
||||
class DefaultDateTimeItemTransformer implements DateTimeItemTransformer
|
||||
{
|
||||
public function __construct(private Config $config)
|
||||
{}
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
private Config\ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @throws BadRequest
|
||||
@@ -61,7 +63,7 @@ class DefaultDateTimeItemTransformer implements DateTimeItemTransformer
|
||||
throw new BadRequest("Bad where item.");
|
||||
}
|
||||
|
||||
$timeZone = $data->getTimeZone() ?? $this->config->get('timeZone') ?? 'UTC';
|
||||
$timeZone = $data->getTimeZone() ?? $this->applicationConfig->getTimeZone();
|
||||
|
||||
if (!$attribute) {
|
||||
throw new BadRequest("Bad datetime where item. Empty 'attribute'.");
|
||||
|
||||
@@ -68,7 +68,8 @@ class ItemGeneralConverter implements ItemConverter
|
||||
private RandomStringGenerator $randomStringGenerator,
|
||||
private ORMDefs $ormDefs,
|
||||
private Config $config,
|
||||
private Metadata $metadata
|
||||
private Metadata $metadata,
|
||||
private Config\ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -1661,7 +1662,7 @@ class ItemGeneralConverter implements ItemConverter
|
||||
|
||||
private function getSystemTimeZone(): DateTimeZone
|
||||
{
|
||||
$timeZone = $this->config->get('timeZone') ?? 'UTC';
|
||||
$timeZone = $this->applicationConfig->getTimeZone();
|
||||
|
||||
try {
|
||||
return new DateTimeZone($timeZone);
|
||||
|
||||
@@ -420,8 +420,7 @@ class Config
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Move to another class `Espo\Core\Utils\Config\ApplicationConfigProvider`.
|
||||
* @deprecated
|
||||
* @deprecated Use Espo\Core\Config\ApplicationConfig
|
||||
*/
|
||||
public function getSiteUrl(): string
|
||||
{
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils\Config;
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
|
||||
/**
|
||||
* @since 9.0.0
|
||||
*/
|
||||
class ApplicationConfig
|
||||
{
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
) {}
|
||||
|
||||
public function getSiteUrl(): string
|
||||
{
|
||||
return rtrim($this->config->get('siteUrl'), '/');
|
||||
}
|
||||
|
||||
public function getDateFormat(): string
|
||||
{
|
||||
return $this->config->get('dateFormat') ?? 'DD.MM.YYYY';
|
||||
}
|
||||
|
||||
public function getTimeFormat(): string
|
||||
{
|
||||
return $this->config->get('timeFormat') ?? 'HH:mm';
|
||||
}
|
||||
|
||||
public function getTimeZone(): string
|
||||
{
|
||||
return $this->config->get('timeZone') ?? 'UTC';
|
||||
}
|
||||
|
||||
public function getLanguage(): string
|
||||
{
|
||||
return $this->config->get('language') ?? 'en_US';
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,10 @@
|
||||
|
||||
namespace Espo\Core\Utils\DateTime;
|
||||
|
||||
use Espo\Core\Utils\Config\ApplicationConfig;
|
||||
use Espo\Core\Utils\DateTime;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\ORM\EntityManager;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Entities\User;
|
||||
use Espo\Entities\Preferences;
|
||||
|
||||
@@ -41,14 +41,14 @@ class DateTimeFactory
|
||||
public function __construct(
|
||||
private InjectableFactory $injectableFactory,
|
||||
private EntityManager $entityManager,
|
||||
private Config $config
|
||||
private ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
public function createWithUserTimeZone(User $user): DateTime
|
||||
{
|
||||
$preferences = $this->entityManager->getEntityById(Preferences::ENTITY_TYPE, $user->getId());
|
||||
|
||||
$timeZone = $this->config->get('timeZone') ?? 'UTC';
|
||||
$timeZone = $this->applicationConfig->getTimeZone();
|
||||
|
||||
if ($preferences) {
|
||||
$timeZone = $preferences->get('timeZone') ? $preferences->get('timeZone') : $timeZone;
|
||||
@@ -61,9 +61,9 @@ class DateTimeFactory
|
||||
{
|
||||
return $this->injectableFactory->createWith(DateTime::class, [
|
||||
'timeZone' => $timeZone,
|
||||
'dateFormat' => $this->config->get('dateFormat'),
|
||||
'timeFormat' => $this->config->get('timeFormat'),
|
||||
'language' => $this->config->get('language'),
|
||||
'dateFormat' => $this->applicationConfig->getDateFormat(),
|
||||
'timeFormat' => $this->applicationConfig->getTimeFormat(),
|
||||
'language' => $this->applicationConfig->getLanguage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,8 @@ class UpcomingService
|
||||
private Metadata $metadata,
|
||||
private Acl $acl,
|
||||
private EntityManager $entityManager,
|
||||
private ServiceContainer $serviceContainer
|
||||
private ServiceContainer $serviceContainer,
|
||||
private Config\ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -250,7 +251,7 @@ class UpcomingService
|
||||
}
|
||||
}
|
||||
|
||||
return $this->config->get('timeZone') ?? 'UTC';
|
||||
return $this->applicationConfig->getTimeZone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -82,6 +82,7 @@ class Service
|
||||
private User $user,
|
||||
private ServiceFactory $serviceFactory,
|
||||
private RelationQueryHelper $relationQueryHelper,
|
||||
private Config\ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -1036,6 +1037,6 @@ class Service
|
||||
return $preferences->getTimeZone();
|
||||
}
|
||||
|
||||
return $this->config->get('timeZone') ?? 'UTC';
|
||||
return $this->applicationConfig->getTimeZone();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\Field\LinkParent;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Notification\EmailNotificationHandler;
|
||||
use Espo\Core\Mail\SenderParams;
|
||||
use Espo\Core\Utils\Config\ApplicationConfig;
|
||||
use Espo\Core\Utils\DateTime as DateTimeUtil;
|
||||
use Espo\Entities\Note;
|
||||
use Espo\ORM\Collection;
|
||||
@@ -84,7 +85,8 @@ class Processor
|
||||
private Metadata $metadata,
|
||||
private Language $language,
|
||||
private Log $log,
|
||||
private NoteAccessControl $noteAccessControl
|
||||
private NoteAccessControl $noteAccessControl,
|
||||
private ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
public function process(): void
|
||||
@@ -583,7 +585,7 @@ class Processor
|
||||
$portal = null;
|
||||
|
||||
if (!$user->isPortal()) {
|
||||
return $this->config->getSiteUrl();
|
||||
return $this->applicationConfig->getSiteUrl();
|
||||
}
|
||||
|
||||
if (!array_key_exists($user->getId(), $this->userIdPortalCacheMap)) {
|
||||
@@ -619,7 +621,7 @@ class Processor
|
||||
return rtrim($portal->get('url'), '/');
|
||||
}
|
||||
|
||||
return $this->config->getSiteUrl();
|
||||
return $this->applicationConfig->getSiteUrl();
|
||||
}
|
||||
|
||||
protected function processNotificationNoteStatus(Note $note, User $user): void
|
||||
|
||||
@@ -43,13 +43,13 @@ use RuntimeException;
|
||||
class CurrentYear implements Placeholder
|
||||
{
|
||||
public function __construct(
|
||||
private Config $config
|
||||
private Config\ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
public function get(Data $data): string
|
||||
{
|
||||
try {
|
||||
$now = new DateTime('now', new DateTimezone($this->config->get('timeZone')));
|
||||
$now = new DateTime('now', new DateTimezone($this->applicationConfig->getTimeZone()));
|
||||
} catch (Exception $e) {
|
||||
throw new RuntimeException($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ class DateTime implements CellValuePreparator
|
||||
{
|
||||
private string $timezone;
|
||||
|
||||
public function __construct(Config $config)
|
||||
public function __construct(Config\ApplicationConfig $applicationConfig)
|
||||
{
|
||||
$this->timezone = $config->get('timeZone') ?? 'UTC';
|
||||
$this->timezone = $applicationConfig->getTimeZone();
|
||||
}
|
||||
|
||||
public function prepare(Entity $entity, string $name): ?DateTimeValue
|
||||
|
||||
@@ -41,9 +41,9 @@ class DateTimeOptional implements CellValuePreparator
|
||||
{
|
||||
private string $timezone;
|
||||
|
||||
public function __construct(Config $config)
|
||||
public function __construct(Config\ApplicationConfig $applicationConfig)
|
||||
{
|
||||
$this->timezone = $config->get('timeZone') ?? 'UTC';
|
||||
$this->timezone = $applicationConfig->getTimeZone();
|
||||
}
|
||||
|
||||
public function prepare(Entity $entity, string $name): DateTimeValue|DateValue|null
|
||||
|
||||
@@ -33,6 +33,7 @@ use Espo\Core\Field\Currency;
|
||||
use Espo\Core\Field\Date;
|
||||
use Espo\Core\Field\DateTime as DateTimeValue;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Utils\Config\ApplicationConfig;
|
||||
use Espo\Entities\Attachment;
|
||||
use Espo\Core\FileStorage\Manager as FileStorageManager;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
@@ -110,7 +111,8 @@ class PhpSpreadsheetProcessor implements ProcessorInterface
|
||||
private EntityManager $entityManager,
|
||||
private FileStorageManager $fileStorageManager,
|
||||
private FieldHelper $fieldHelper,
|
||||
private CellValuePreparatorFactory $cellValuePreparatorFactory
|
||||
private CellValuePreparatorFactory $cellValuePreparatorFactory,
|
||||
private ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -511,7 +513,7 @@ class PhpSpreadsheetProcessor implements ProcessorInterface
|
||||
[$foreignLink, $foreignField] = explode('_', $name);
|
||||
}
|
||||
|
||||
$siteUrl = $this->config->getSiteUrl();
|
||||
$siteUrl = $this->applicationConfig->getSiteUrl();
|
||||
|
||||
if ($name === 'name') {
|
||||
if ($entity->hasId()) {
|
||||
|
||||
@@ -35,7 +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;
|
||||
use Espo\Entities\Email;
|
||||
@@ -50,31 +50,16 @@ use Espo\Tools\EmailTemplate\Processor as EmailTemplateProcessor;
|
||||
|
||||
class ConfirmationSender
|
||||
{
|
||||
private EntityManager $entityManager;
|
||||
private Config $config;
|
||||
private Language $defaultLanguage;
|
||||
private EmailSender $emailSender;
|
||||
private AccountFactory $accountFactory;
|
||||
private DateTime $dateTime;
|
||||
private EmailTemplateProcessor $emailTemplateProcessor;
|
||||
|
||||
public function __construct(
|
||||
EntityManager $entityManager,
|
||||
Config $config,
|
||||
Language $defaultLanguage,
|
||||
EmailSender $emailSender,
|
||||
AccountFactory $accountFactory,
|
||||
DateTime $dateTime,
|
||||
EmailTemplateProcessor $emailTemplateProcessor
|
||||
) {
|
||||
$this->entityManager = $entityManager;
|
||||
$this->config = $config;
|
||||
$this->defaultLanguage = $defaultLanguage;
|
||||
$this->emailSender = $emailSender;
|
||||
$this->accountFactory = $accountFactory;
|
||||
$this->dateTime = $dateTime;
|
||||
$this->emailTemplateProcessor = $emailTemplateProcessor;
|
||||
}
|
||||
private EntityManager $entityManager,
|
||||
private Language $defaultLanguage,
|
||||
private EmailSender $emailSender,
|
||||
private AccountFactory $accountFactory,
|
||||
private DateTime $dateTime,
|
||||
private EmailTemplateProcessor $emailTemplateProcessor,
|
||||
private ApplicationConfig $appConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Send opt-in confirmation email.
|
||||
@@ -181,7 +166,7 @@ class ConfirmationSender
|
||||
}
|
||||
}
|
||||
|
||||
$url = $this->config->getSiteUrl() . '/?entryPoint=confirmOptIn&id=' . $uniqueId->getIdValue();
|
||||
$url = $this->appConfig->getSiteUrl() . '/?entryPoint=confirmOptIn&id=' . $uniqueId->getIdValue();
|
||||
|
||||
$linkHtml =
|
||||
'<a href='.$url.'>' .
|
||||
@@ -194,8 +179,8 @@ class ConfirmationSender
|
||||
$createdAt = $uniqueId->getCreatedAt()->toString();
|
||||
|
||||
if ($createdAt) {
|
||||
$dateString = $this->dateTime->convertSystemDateTime($createdAt, null, $this->config->get('dateFormat'));
|
||||
$timeString = $this->dateTime->convertSystemDateTime($createdAt, null, $this->config->get('timeFormat'));
|
||||
$dateString = $this->dateTime->convertSystemDateTime($createdAt, null, $this->appConfig->getDateFormat());
|
||||
$timeString = $this->dateTime->convertSystemDateTime($createdAt, null, $this->appConfig->getTimeFormat());
|
||||
$dateTimeString = $this->dateTime->convertSystemDateTime($createdAt);
|
||||
|
||||
$body = str_replace('{optInDate}', $dateString, $body);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Tools\Stream;
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\ApplicationConfig;
|
||||
use Espo\Entities\Note;
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ use Espo\Entities\Note;
|
||||
*/
|
||||
class NoteUtil
|
||||
{
|
||||
public function __construct(private Config $config) {}
|
||||
public function __construct(private ApplicationConfig $applicationConfig) {}
|
||||
|
||||
public function handlePostText(Note $entity): void
|
||||
{
|
||||
@@ -47,7 +47,7 @@ class NoteUtil
|
||||
return;
|
||||
}
|
||||
|
||||
$siteUrl = $this->config->getSiteUrl();
|
||||
$siteUrl = $this->applicationConfig->getSiteUrl();
|
||||
|
||||
// PhpStorm inspection highlights RegExpRedundantEscape by a mistake.
|
||||
/** @noinspection RegExpRedundantEscape */
|
||||
|
||||
@@ -39,6 +39,7 @@ use Espo\Core\Job\JobSchedulerFactory;
|
||||
use Espo\Core\Mail\Exceptions\NoSmtp;
|
||||
use Espo\Core\Mail\Exceptions\SendingError;
|
||||
use Espo\Core\Mail\SmtpParams;
|
||||
use Espo\Core\Utils\Config\ApplicationConfig;
|
||||
use Espo\Core\Utils\Util;
|
||||
use Espo\Entities\Email;
|
||||
use Espo\Entities\SystemData;
|
||||
@@ -77,7 +78,8 @@ class RecoveryService
|
||||
private JobSchedulerFactory $jobSchedulerFactory,
|
||||
private ApplicationState $applicationState,
|
||||
private AuthenticationMethodProvider $authenticationMethodProvider,
|
||||
private UrlValidator $urlValidator
|
||||
private UrlValidator $urlValidator,
|
||||
private ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -404,7 +406,7 @@ class RecoveryService
|
||||
$subjectTpl = $this->templateFileManager->getTemplate('passwordChangeLink', 'subject', 'User');
|
||||
$bodyTpl = $this->templateFileManager->getTemplate('passwordChangeLink', 'body', 'User');
|
||||
|
||||
$siteUrl = $this->config->getSiteUrl();
|
||||
$siteUrl = $this->applicationConfig->getSiteUrl();
|
||||
|
||||
if ($user->isPortal()) {
|
||||
/** @var ?Portal $portal */
|
||||
|
||||
@@ -35,7 +35,7 @@ use Espo\Core\Mail\EmailSender;
|
||||
use Espo\Core\Mail\Exceptions\NoSmtp;
|
||||
use Espo\Core\Mail\Exceptions\SendingError;
|
||||
use Espo\Core\Mail\Sender as EmailSenderSender;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\ApplicationConfig;
|
||||
use Espo\Core\Utils\TemplateFileManager;
|
||||
use Espo\Entities\Email;
|
||||
use Espo\Entities\PasswordChangeRequest;
|
||||
@@ -47,11 +47,11 @@ use Espo\Repositories\Portal as PortalRepository;
|
||||
class Sender
|
||||
{
|
||||
public function __construct(
|
||||
private Config $config,
|
||||
private EmailSender $emailSender,
|
||||
private EntityManager $entityManager,
|
||||
private HtmlizerFactory $htmlizerFactory,
|
||||
private TemplateFileManager $templateFileManager
|
||||
private TemplateFileManager $templateFileManager,
|
||||
private ApplicationConfig $applicationConfig,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ class Sender
|
||||
$urlSuffix = '?entryPoint=changePassword&id=' . $passwordChangeRequest->getRequestId();
|
||||
}
|
||||
|
||||
$siteUrl = $this->config->getSiteUrl() . '/' . $urlSuffix;
|
||||
$siteUrl = $this->applicationConfig->getSiteUrl() . '/' . $urlSuffix;
|
||||
|
||||
if ($user->isPortal()) {
|
||||
$subjectTpl = $this->templateFileManager
|
||||
|
||||
@@ -51,6 +51,7 @@ class GlobalCalendar implements Calendar
|
||||
private EntityManager $entityManager,
|
||||
private Config $config,
|
||||
private InjectableFactory $injectableFactory,
|
||||
private Config\ApplicationConfig $applicationConfig,
|
||||
) {
|
||||
$this->initDefault();
|
||||
|
||||
@@ -92,7 +93,7 @@ class GlobalCalendar implements Calendar
|
||||
}
|
||||
|
||||
try {
|
||||
return new DateTimeZone($this->config->get('timeZone'));
|
||||
return new DateTimeZone($this->applicationConfig->getTimeZone());
|
||||
} catch (Exception $e) {
|
||||
throw new RuntimeException($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
namespace Espo\Tools\WorkingTime;
|
||||
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Config\ApplicationConfig;
|
||||
use Espo\Entities\WorkingTimeCalendar;
|
||||
use Espo\Entities\WorkingTimeRange;
|
||||
use Espo\ORM\EntityManager;
|
||||
@@ -59,11 +59,11 @@ class SpecificCalendar implements Calendar
|
||||
|
||||
public function __construct(
|
||||
private EntityManager $entityManager,
|
||||
Config $config,
|
||||
private WorkingTimeCalendar $workingTimeCalendar,
|
||||
ApplicationConfig $applicationConfig,
|
||||
) {
|
||||
try {
|
||||
$this->timezone = new DateTimeZone($config->get('timeZone'));
|
||||
$this->timezone = new DateTimeZone($applicationConfig->getTimeZone());
|
||||
} catch (Exception $e) {
|
||||
throw new RuntimeException($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -60,10 +60,11 @@ class TeamCalendar implements Calendar
|
||||
public function __construct(
|
||||
private Team $team,
|
||||
private EntityManager $entityManager,
|
||||
private Config $config
|
||||
private Config $config,
|
||||
Config\ApplicationConfig $applicationConfig,
|
||||
) {
|
||||
try {
|
||||
$this->timezone = new DateTimeZone($config->get('timeZone'));
|
||||
$this->timezone = new DateTimeZone($applicationConfig->getTimeZone());
|
||||
} catch (Exception $e) {
|
||||
throw new RuntimeException($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -59,10 +59,11 @@ class UserCalendar implements Calendar
|
||||
public function __construct(
|
||||
private User $user,
|
||||
private EntityManager $entityManager,
|
||||
private Config $config
|
||||
private Config $config,
|
||||
Config\ApplicationConfig $applicationConfig,
|
||||
) {
|
||||
try {
|
||||
$this->timezone = new DateTimeZone($config->get('timeZone'));
|
||||
$this->timezone = new DateTimeZone($applicationConfig->getTimeZone());
|
||||
} catch (Exception $e) {
|
||||
throw new RuntimeException($e->getMessage());
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace tests\unit\Espo\Core\Formula;
|
||||
|
||||
use Espo\Core\Binding\BindingContainerBuilder;
|
||||
use Espo\Core\Formula\AttributeFetcher;
|
||||
use Espo\Core\Formula\Parser\Ast\Attribute;
|
||||
use Espo\Core\Formula\Parser\Ast\Node;
|
||||
@@ -36,29 +37,23 @@ use Espo\Core\Formula\Parser\Ast\Value;
|
||||
use Espo\Core\Formula\Parser\Ast\Variable;
|
||||
use Espo\Core\Formula\Processor;
|
||||
use Espo\Core\Formula\Argument;
|
||||
|
||||
use Espo\Core\Utils\DateTime;
|
||||
use Espo\Core\Utils\NumberUtil;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Log;
|
||||
|
||||
use Espo\Core\Repositories\Database as DatabaseRepository;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
|
||||
use Espo\Entities\User;
|
||||
|
||||
use Espo\ORM\Entity as Entity;
|
||||
|
||||
use Espo\Core\ORM\Entity as CoreEntity;
|
||||
|
||||
use Espo\Core\InjectableFactory;
|
||||
|
||||
use Espo\ORM\Repository\RDBRelation;
|
||||
use Espo\ORM\Repository\RDBRepository;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use stdClass;
|
||||
use tests\unit\ContainerMocker;
|
||||
|
||||
class FormulaTest extends \PHPUnit\Framework\TestCase
|
||||
class FormulaTest extends TestCase
|
||||
{
|
||||
protected function setUp() : void
|
||||
{
|
||||
@@ -72,7 +67,7 @@ class FormulaTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
$this->number = new NumberUtil();
|
||||
|
||||
$this->config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
|
||||
$this->config = $this->createMock(Config::class);
|
||||
$this->config
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
@@ -80,6 +75,12 @@ class FormulaTest extends \PHPUnit\Framework\TestCase
|
||||
['timeZone', null, 'UTC']
|
||||
]));
|
||||
|
||||
$this->applicationConfig = $this->createMock(Config\ApplicationConfig::class);
|
||||
$this->applicationConfig
|
||||
->expects($this->any())
|
||||
->method('getTimeZone')
|
||||
->willReturn('UTC');
|
||||
|
||||
$this->user = $this->getMockBuilder(User::class)->disableOriginalConstructor()->getMock();
|
||||
|
||||
$this->log = $this->getMockBuilder(Log::class)->disableOriginalConstructor()->getMock();
|
||||
@@ -134,7 +135,13 @@ class FormulaTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
protected function createProcessor($variables = null, ?Entity $entity = null)
|
||||
{
|
||||
$injectableFactory = new InjectableFactory($this->container);
|
||||
$injectableFactory = new InjectableFactory(
|
||||
$this->container,
|
||||
BindingContainerBuilder::create()
|
||||
->bindInstance(Config\ApplicationConfig::class, $this->applicationConfig)
|
||||
->build()
|
||||
);
|
||||
|
||||
$attributeFetcher = new AttributeFetcher($this->entityManager);
|
||||
|
||||
return new Processor(
|
||||
|
||||
@@ -61,6 +61,7 @@ class ConverterTest extends TestCase
|
||||
$this->user = $this->createMock(User::class);
|
||||
|
||||
$this->config = $this->createMock(Config::class);
|
||||
$this->applicationConfig = $this->createMock(Config\ApplicationConfig::class);
|
||||
$this->metadata = $this->createMock(Metadata::class);
|
||||
|
||||
$this->scanner = $this->createMock(Scanner::class);
|
||||
@@ -91,7 +92,12 @@ class ConverterTest extends TestCase
|
||||
->method('generate')
|
||||
->willReturn('Random');
|
||||
|
||||
$this->dateTimeItemTransformer = new DefaultDateTimeItemTransformer($this->config);
|
||||
$this->applicationConfig
|
||||
->expects($this->any())
|
||||
->method('getTimeZone')
|
||||
->willReturn('UTC');
|
||||
|
||||
$this->dateTimeItemTransformer = new DefaultDateTimeItemTransformer($this->config, $this->applicationConfig);
|
||||
|
||||
$this->itemConverter = new ItemGeneralConverter(
|
||||
$this->entityType,
|
||||
@@ -102,7 +108,8 @@ class ConverterTest extends TestCase
|
||||
$this->randomStringGenerator,
|
||||
$this->ormDefs,
|
||||
$this->config,
|
||||
$this->metadata
|
||||
$this->metadata,
|
||||
$this->applicationConfig,
|
||||
);
|
||||
|
||||
$this->converter = new Converter(
|
||||
|
||||
@@ -64,7 +64,7 @@ class NoteUtilTest extends TestCase
|
||||
|
||||
private function initText(string $post, string $newPost): void
|
||||
{
|
||||
$config = $this->createMock(Config::class);
|
||||
$config = $this->createMock(Config\ApplicationConfig::class);
|
||||
$note = $this->createMock(Note::class);
|
||||
|
||||
$config->expects($this->once())
|
||||
|
||||
Reference in New Issue
Block a user