Skip to content

Commit

Permalink
OXDEV-7521 Remove module setting repository
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Fedurtsya <anton@fedurtsya.com>
  • Loading branch information
Sieg committed Dec 5, 2023
1 parent 9b8abd8 commit 019c7ca
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 509 deletions.
84 changes: 0 additions & 84 deletions src/Setting/Infrastructure/ModuleSettingRepository.php

This file was deleted.

38 changes: 0 additions & 38 deletions src/Setting/Infrastructure/ModuleSettingRepositoryInterface.php

This file was deleted.

36 changes: 22 additions & 14 deletions src/Setting/Service/ModuleSettingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,63 @@

namespace OxidEsales\GraphQL\ConfigurationAccess\Setting\Service;

use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ModuleConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\{
ModuleSettingServiceInterface as ShopModuleSettingServiceInterface
};
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Setting;
use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface;
use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\BooleanSetting;
use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\FloatSetting;
use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\IntegerSetting;
use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\SettingType;
use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\StringSetting;
use OxidEsales\GraphQL\ConfigurationAccess\Setting\Infrastructure\ModuleSettingRepositoryInterface;

final class ModuleSettingService implements ModuleSettingServiceInterface
{
public function __construct(
private ModuleSettingRepositoryInterface $moduleSettingRepository,
private JsonServiceInterface $jsonService
private JsonServiceInterface $jsonService,
private ShopModuleSettingServiceInterface $moduleSettingService,
private ModuleConfigurationDaoInterface $moduleConfigurationDao,
private BasicContextInterface $basicContext,
) {
}

public function getIntegerSetting(string $name, string $moduleId): IntegerSetting
{
return new IntegerSetting(
$name,
$this->moduleSettingRepository->getIntegerSetting($name, $moduleId)
$this->moduleSettingService->getInteger($name, $moduleId)
);
}

public function getFloatSetting(string $name, string $moduleId): FloatSetting
{
return new FloatSetting(
$name,
$this->moduleSettingRepository->getFloatSetting($name, $moduleId)
$this->moduleSettingService->getFloat($name, $moduleId)
);
}

public function getBooleanSetting(string $name, string $moduleId): BooleanSetting
{
return new BooleanSetting(
$name,
$this->moduleSettingRepository->getBooleanSetting($name, $moduleId)
$this->moduleSettingService->getBoolean($name, $moduleId)
);
}

public function getStringSetting(string $name, string $moduleId): StringSetting
{
return new StringSetting(
$name,
$this->moduleSettingRepository->getStringSetting($name, $moduleId)
(string)$this->moduleSettingService->getString($name, $moduleId)
);
}

public function getCollectionSetting(string $name, string $moduleId): StringSetting
{
$collection = $this->moduleSettingRepository->getCollectionSetting($name, $moduleId);
$collection = $this->moduleSettingService->getCollection($name, $moduleId);

return new StringSetting(
$name,
Expand All @@ -69,35 +75,35 @@ public function getCollectionSetting(string $name, string $moduleId): StringSett

public function changeIntegerSetting(string $name, int $value, string $moduleId): IntegerSetting
{
$this->moduleSettingRepository->saveIntegerSetting($name, $value, $moduleId);
$this->moduleSettingService->saveInteger($name, $value, $moduleId);

return $this->getIntegerSetting($name, $moduleId);
}

public function changeFloatSetting(string $name, float $value, string $moduleId): FloatSetting
{
$this->moduleSettingRepository->saveFloatSetting($name, $value, $moduleId);
$this->moduleSettingService->saveFloat($name, $value, $moduleId);

return $this->getFloatSetting($name, $moduleId);
}

public function changeBooleanSetting(string $name, bool $value, string $moduleId): BooleanSetting
{
$this->moduleSettingRepository->saveBooleanSetting($name, $value, $moduleId);
$this->moduleSettingService->saveBoolean($name, $value, $moduleId);

return $this->getBooleanSetting($name, $moduleId);
}

public function changeStringSetting(string $name, string $value, string $moduleId): StringSetting
{
$this->moduleSettingRepository->saveStringSetting($name, $value, $moduleId);
$this->moduleSettingService->saveString($name, $value, $moduleId);

return $this->getStringSetting($name, $moduleId);
}

public function changeCollectionSetting(string $name, string $value, string $moduleId): StringSetting
{
$this->moduleSettingRepository->saveCollectionSetting(
$this->moduleSettingService->saveCollection(
$name,
$this->jsonService->jsonDecodeCollection($value),
$moduleId
Expand All @@ -111,7 +117,9 @@ public function changeCollectionSetting(string $name, string $value, string $mod
*/
public function getSettingsList(string $moduleId): array
{
$settingsList = $this->moduleSettingRepository->getSettingsList($moduleId);
$moduleConfiguration = $this->moduleConfigurationDao->get($moduleId, $this->basicContext->getCurrentShopId());
$settingsList = $moduleConfiguration->getModuleSettings();

$settingTypes = [];
/** @var Setting $setting */
foreach ($settingsList as $setting) {
Expand Down
3 changes: 0 additions & 3 deletions src/Setting/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ services:
OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ThemeSettingServiceInterface:
class: OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ThemeSettingService

OxidEsales\GraphQL\ConfigurationAccess\Setting\Infrastructure\ModuleSettingRepositoryInterface:
class: OxidEsales\GraphQL\ConfigurationAccess\Setting\Infrastructure\ModuleSettingRepository

OxidEsales\GraphQL\ConfigurationAccess\Setting\Infrastructure\ThemeSettingRepositoryInterface:
class: OxidEsales\GraphQL\ConfigurationAccess\Setting\Infrastructure\ThemeSettingRepository

Expand Down
Loading

0 comments on commit 019c7ca

Please sign in to comment.