Skip to content

Commit

Permalink
IBX-5143: Fixed autosave default value (#2093)
Browse files Browse the repository at this point in the history
  • Loading branch information
reithor authored Feb 24, 2023
1 parent a247464 commit 3be546d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/lib/UserSetting/Autosave.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 3be546d

Please # to comment.