From 3be546d62a438b91ed7f9cc376b1e5c83caa5fc0 Mon Sep 17 00:00:00 2001 From: Thorsten Reiter <34274688+reithor@users.noreply.github.com> Date: Fri, 24 Feb 2023 11:50:06 +0100 Subject: [PATCH] IBX-5143: Fixed autosave default value (#2093) --- src/lib/UserSetting/Autosave.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/UserSetting/Autosave.php b/src/lib/UserSetting/Autosave.php index 6d60a4b651..19e6e131d5 100644 --- a/src/lib/UserSetting/Autosave.php +++ b/src/lib/UserSetting/Autosave.php @@ -9,6 +9,7 @@ namespace EzSystems\EzPlatformAdminUi\UserSetting; use eZ\Publish\Core\Base\Exceptions\InvalidArgumentException; +use eZ\Publish\Core\MVC\ConfigResolverInterface; use EzSystems\EzPlatformUser\UserSetting\FormMapperInterface; use EzSystems\EzPlatformUser\UserSetting\ValueDefinitionInterface; use JMS\TranslationBundle\Annotation\Desc; @@ -24,10 +25,15 @@ class Autosave implements ValueDefinitionInterface, FormMapperInterface /** @var \Symfony\Contracts\Translation\TranslatorInterface */ private $translator; + /** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */ + private $configResolver; + public function __construct( - TranslatorInterface $translator + TranslatorInterface $translator, + ConfigResolverInterface $configResolver ) { $this->translator = $translator; + $this->configResolver = $configResolver; } public function getName(): string @@ -57,7 +63,7 @@ public function getDisplayValue(string $storageValue): string public function getDefaultValue(): string { - return self::ENABLED_OPTION; + return $this->configResolver->getParameter('autosave.enabled') == false ? self::DISABLED_OPTION : self::ENABLED_OPTION; } public function mapFieldForm(