Permalink
Browse files

Merge branch 'b-6.x'

  • Loading branch information...
iegupov committed Jan 8, 2019
2 parents 0fe8f82 + 82db361 commit e7ce86f53598e809915401ff21d2a096bb995e7d
Showing with 12,810 additions and 218 deletions.
  1. +9 −0 CHANGELOG.md
  2. +1 −0 composer.json
  3. +7 −8 source/Core/Module/ModuleInstaller.php
  4. +149 −0 source/Internal/Adapter/Configuration/Dao/ShopConfigurationSettingDao.php
  5. +37 −0 source/Internal/Adapter/Configuration/Dao/ShopConfigurationSettingDaoInterface.php
  6. +118 −0 source/Internal/Adapter/Configuration/DataObject/ShopConfigurationSetting.php
  7. +19 −0 source/Internal/Adapter/Configuration/DataObject/ShopSettingType.php
  8. +16 −0 source/Internal/Adapter/Configuration/Exception/InvalidShopSettingValueException.php
  9. +79 −0 source/Internal/Adapter/Configuration/Service/ShopSettingEncoder.php
  10. +29 −0 source/Internal/Adapter/Configuration/Service/ShopSettingEncoderInterface.php
  11. +16 −0 source/Internal/Adapter/Exception/ModuleNotLoadableException.php
  12. +108 −2 source/Internal/Adapter/ShopAdapter.php
  13. +49 −2 source/Internal/Adapter/ShopAdapterInterface.php
  14. +9 −0 source/Internal/Adapter/services.yaml
  15. +2 −2 source/Internal/Application/ContainerBuilder.php
  16. +1 −1 source/Internal/Application/services.yaml
  17. +52 −0 source/Internal/Common/Database/TransactionService.php
  18. +28 −0 source/Internal/Common/Database/TransactionServiceInterface.php
  19. +14 −0 source/Internal/Common/Exception/DirectoryNotExistentException.php
  20. +14 −0 source/Internal/Common/Exception/DirectoryNotReadableException.php
  21. +16 −0 source/Internal/Common/Exception/UnsupportedMethodException.php
  22. +27 −0 source/Internal/Common/StateMachine/StateMachineInterface.php
  23. +25 −0 source/Internal/Common/Storage/ArrayStorageInterface.php
  24. +103 −0 source/Internal/Common/Storage/YamlFileStorage.php
  25. +10 −2 source/Internal/Common/services.yaml
  26. +51 −0 source/Internal/Module/Cache/InvalidateModuleCacheEventSubscriber.php
  27. +24 −0 source/Internal/Module/Cache/ModuleCacheServiceInterface.php
  28. +45 −0 source/Internal/Module/Cache/ShopModuleCacheService.php
  29. +9 −0 source/Internal/Module/Cache/services.yaml
  30. +70 −0 source/Internal/Module/Configuration/Dao/ModuleConfigurationDao.php
  31. +28 −0 source/Internal/Module/Configuration/Dao/ModuleConfigurationDaoInterface.php
  32. +74 −0 source/Internal/Module/Configuration/Dao/ProjectConfigurationDao.php
  33. +25 −0 source/Internal/Module/Configuration/Dao/ProjectConfigurationDaoInterface.php
  34. +114 −0 source/Internal/Module/Configuration/DataMapper/ModuleConfigurationDataMapper.php
  35. +30 −0 source/Internal/Module/Configuration/DataMapper/ModuleConfigurationDataMapperInterface.php
  36. +120 −0 source/Internal/Module/Configuration/DataMapper/ProjectConfigurationDataMapper.php
  37. +27 −0 source/Internal/Module/Configuration/DataMapper/ProjectConfigurationDataMapperInterface.php
  38. +125 −0 source/Internal/Module/Configuration/DataMapper/ShopConfigurationDataMapper.php
  39. +29 −0 source/Internal/Module/Configuration/DataMapper/ShopConfigurationDataMapperInterface.php
  40. +62 −0 source/Internal/Module/Configuration/DataObject/Chain.php
  41. +74 −0 source/Internal/Module/Configuration/DataObject/EnvironmentConfiguration.php
  42. +332 −0 source/Internal/Module/Configuration/DataObject/ModuleConfiguration.php
  43. +62 −0 source/Internal/Module/Configuration/DataObject/ModuleSetting.php
  44. +74 −0 source/Internal/Module/Configuration/DataObject/ProjectConfiguration.php
  45. +106 −0 source/Internal/Module/Configuration/DataObject/ShopConfiguration.php
  46. +136 −0 source/Internal/Module/Configuration/Definition/TreeBuilderFactory.php
  47. +20 −0 source/Internal/Module/Configuration/Definition/TreeBuilderFactoryInterface.php
  48. +47 −0 source/Internal/Module/Configuration/services.yaml
  49. +124 −0 source/Internal/Module/MetaData/DataMapper/MetaDataMapper.php
  50. +22 −0 source/Internal/Module/MetaData/DataMapper/MetaDataToModuleConfigurationDataMapperInterface.php
  51. +58 −0 source/Internal/Module/MetaData/Event/BadMetaDataFoundEvent.php
  52. +15 −0 source/Internal/Module/MetaData/Exception/InvalidMetaDataException.php
  53. +15 −0 source/Internal/Module/MetaData/Exception/MetaDataVersionException.php
  54. +15 −0 source/Internal/Module/MetaData/Exception/UnsupportedMetaDataKeyException.php
  55. +15 −0 source/Internal/Module/MetaData/Exception/UnsupportedMetaDataValueTypeException.php
  56. +14 −0 source/Internal/Module/MetaData/Exception/UnsupportedMetaDataVersionException.php
  57. +73 −0 source/Internal/Module/MetaData/Service/MetaDataNormalizer.php
  58. +22 −0 source/Internal/Module/MetaData/Service/MetaDataNormalizerInterface.php
  59. +246 −0 source/Internal/Module/MetaData/Service/MetaDataProvider.php
  60. +102 −0 source/Internal/Module/MetaData/Service/MetaDataSchemataProvider.php
  61. +32 −0 source/Internal/Module/MetaData/Service/MetaDataSchemataProviderInterface.php
  62. +143 −0 source/Internal/Module/MetaData/Validator/MetaDataValidator.php
  63. +20 −0 source/Internal/Module/MetaData/Validator/MetaDataValidatorInterface.php
  64. +19 −0 source/Internal/Module/MetaData/Validator/SettingValidatorInterface.php
  65. +61 −0 source/Internal/Module/MetaData/services.yaml
  66. +17 −0 source/Internal/Module/Setup/Event/BeforeModuleDeactivationEvent.php
  67. +15 −0 source/Internal/Module/Setup/Event/FinalizingModuleActivationEvent.php
  68. +15 −0 source/Internal/Module/Setup/Event/FinalizingModuleDeactivationEvent.php
  69. +47 −0 source/Internal/Module/Setup/Event/ModuleSetupEvent.php
  70. +85 −0 source/Internal/Module/Setup/EventSubscriber/DispatchLegacyEventsSubscriber.php
  71. +14 −0 source/Internal/Module/Setup/Exception/ControllersDuplicationModuleSettingException.php
  72. +15 −0 source/Internal/Module/Setup/Exception/InvalidClassExtensionNamespaceException.php
  73. +15 −0 source/Internal/Module/Setup/Exception/ModuleSettingHandlerNotFoundException.php
  74. +15 −0 source/Internal/Module/Setup/Exception/ModuleSettingNotValidException.php
  75. +15 −0 source/Internal/Module/Setup/Exception/ModuleSetupException.php
  76. +14 −0 source/Internal/Module/Setup/Exception/ModuleSetupValidationException.php
  77. +25 −0 source/Internal/Module/Setup/Exception/WrongModuleSettingException.php
  78. +112 −0 source/Internal/Module/Setup/Handler/ClassExtensionsModuleSettingHandler.php
  79. +136 −0 source/Internal/Module/Setup/Handler/ControllersModuleSettingHandler.php
  80. +40 −0 source/Internal/Module/Setup/Handler/ModuleSettingHandlerInterface.php
  81. +133 −0 source/Internal/Module/Setup/Handler/ShopConfigurationModuleSettingHandler.php
  82. +120 −0 source/Internal/Module/Setup/Handler/ShopModuleSettingModuleSettingHandler.php
  83. +108 −0 source/Internal/Module/Setup/Handler/TemplateBlockModuleSettingHandler.php
  84. +140 −0 source/Internal/Module/Setup/Service/ActiveClassExtensionChainResolver.php
  85. +21 −0 source/Internal/Module/Setup/Service/ActiveClassExtensionChainResolverInterface.php
  86. +92 −0 source/Internal/Module/Setup/Service/ClassExtensionChainService.php
  87. +18 −0 source/Internal/Module/Setup/Service/ExtensionChainServiceInterface.php
  88. +146 −0 source/Internal/Module/Setup/Service/ModuleActivationService.php
  89. +31 −0 source/Internal/Module/Setup/Service/ModuleActivationServiceInterface.php
  90. +34 −16 ...fig/Service/ShopActivationService.php → Module/Setup/Service/ModuleServicesActivationService.php}
  91. +27 −0 source/Internal/Module/Setup/Service/ModuleServicesActivationServiceInterface.php
  92. +105 −0 source/Internal/Module/Setup/Service/ModuleSettingsHandlingService.php
  93. +27 −0 source/Internal/Module/Setup/Service/ModuleSettingsHandlingServiceInterface.php
  94. +80 −0 source/Internal/Module/Setup/Validator/ClassExtensionsModuleSettingValidator.php
  95. +152 −0 source/Internal/Module/Setup/Validator/ControllersModuleSettingValidator.php
  96. +66 −0 source/Internal/Module/Setup/Validator/EventsModuleSettingValidator.php
  97. +28 −0 source/Internal/Module/Setup/Validator/ModuleSettingValidatorInterface.php
  98. +96 −0 source/Internal/Module/Setup/Validator/SmartyPluginDirectoriesModuleSettingValidator.php
  99. +111 −0 source/Internal/Module/Setup/services.yaml
  100. +199 −0 source/Internal/Module/ShopModuleSetting/ShopModuleSetting.php
  101. +309 −0 source/Internal/Module/ShopModuleSetting/ShopModuleSettingDao.php
  102. +34 −0 source/Internal/Module/ShopModuleSetting/ShopModuleSettingDaoInterface.php
  103. +6 −0 source/Internal/Module/ShopModuleSetting/services.yaml
  104. +15 −0 source/Internal/Module/State/ModuleStateIsAlreadySetException.php
  105. +116 −0 source/Internal/Module/State/ModuleStateService.php
  106. +36 −0 source/Internal/Module/State/ModuleStateServiceInterface.php
  107. +4 −0 source/Internal/Module/State/services.yaml
  108. +176 −0 source/Internal/Module/TemplateExtension/TemplateBlockExtension.php
  109. +154 −0 source/Internal/Module/TemplateExtension/TemplateBlockExtensionDao.php
  110. +33 −0 source/Internal/Module/TemplateExtension/TemplateBlockExtensionDaoInterface.php
  111. +4 −0 source/Internal/Module/TemplateExtension/services.yaml
  112. +8 −0 source/Internal/Module/services.yaml
  113. +0 −30 source/Internal/ProjectDIConfig/Service/ShopActivationServiceInterface.php
  114. +0 −7 source/Internal/ProjectDIConfig/services.yaml
  115. +35 −3 source/Internal/Utility/Context.php
  116. +19 −4 source/Internal/Utility/ContextInterface.php
  117. +212 −0 tests/Integration/Internal/Adapter/Configuration/Dao/ShopConfigurationSettingDaoTest.php
  118. +149 −0 tests/Integration/Internal/Common/Storage/YamlFileStorageTest.php
  119. +7 −14 tests/Integration/Internal/ContainerTrait.php
  120. +60 −0 tests/Integration/Internal/Module/Configuration/Dao/ModuleConfigurationDaoTest.php
  121. +245 −0 tests/Integration/Internal/Module/Configuration/Dao/ProjectConfigurationDaoTest.php
  122. +352 −0 tests/Integration/Internal/Module/MetaData/MetaDataMapperTest.php
  123. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleMetaData20/Article.php
  124. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleMetaData20/Controller.php
  125. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleMetaData20/OtherController.php
  126. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleMetaData20/Payment.php
  127. +64 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleMetaData20/metadata.php
  128. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleMetaData21/Article.php
  129. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleMetaData21/Controller.php
  130. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleMetaData21/OtherController.php
  131. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleMetaData21/Payment.php
  132. +66 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleMetaData21/metadata.php
  133. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleWithPartialMetaData/Article.php
  134. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleWithPartialMetaData/Payment.php
  135. +20 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleWithPartialMetaData/metadata.php
  136. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleWithSurplusData/Article.php
  137. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleWithSurplusData/Controller.php
  138. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleWithSurplusData/OtherController.php
  139. +13 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleWithSurplusData/Payment.php
  140. +21 −0 tests/Integration/Internal/Module/MetaData/TestData/TestModuleWithSurplusData/metadata.php
  141. +75 −0 tests/Integration/Internal/Module/Setup/Service/ClassExtensionChainServiceTest.php
  142. +323 −0 tests/Integration/Internal/Module/Setup/Service/ModuleActivationServiceTest.php
  143. +186 −0 tests/Integration/Internal/Module/Setup/Service/ModuleServicesActivationServiceTest.php
  144. +231 −0 tests/Integration/Internal/Module/ShopModuleSetting/ShopModuleSettingDaoTest.php
  145. +79 −0 tests/Integration/Internal/Module/State/ModuleStateServiceTest.php
  146. +80 −0 tests/Integration/Internal/Module/TemplateExtension/TemplateBlockDaoTest.php
  147. +23 −0 tests/Integration/Internal/Module/TestData/TestModule/ModuleEvents.php
  148. 0 tests/Integration/Internal/Module/TestData/TestModule/SmartyPlugins/directory1/.gitkeep
  149. 0 tests/Integration/Internal/Module/TestData/TestModule/SmartyPlugins/directory2/.gitkeep
  150. +19 −0 tests/Integration/Internal/Module/TestData/TestModule/SomeModuleService.php
  151. +27 −0 tests/Integration/Internal/Module/TestData/TestModule/TestEventSubscriber.php
  152. +24 −0 tests/Integration/Internal/Module/TestData/TestModule/metadata.php
  153. +9 −0 tests/Integration/Internal/Module/TestData/TestModule/services.yaml
  154. +52 −0 tests/Integration/Internal/TestContainerFactory.php
  155. +85 −0 tests/Unit/Internal/Adapter/Configuration/Service/ShopSettingEncoderTest.php
  156. +26 −0 tests/Unit/Internal/Adapter/ShopAdapterTest.php
  157. +20 −4 tests/Unit/Internal/ContextStub.php
  158. +44 −0 tests/Unit/Internal/Module/Cache/InvalidateModuleCacheEventSubscriberTest.php
  159. +72 −0 tests/Unit/Internal/Module/Configuration/Dao/ModuleConfigurationDaoTest.php
  160. +102 −0 tests/Unit/Internal/Module/Configuration/Dao/ProjectConfigurationDaoTest.php
  161. +55 −0 tests/Unit/Internal/Module/Configuration/DataMapper/ModuleConfigurationDataMapperTest.php
  162. +100 −0 tests/Unit/Internal/Module/Configuration/DataMapper/ProjectConfigurationDataMapperTest.php
  163. +85 −0 tests/Unit/Internal/Module/Configuration/DataMapper/ShopConfigurationDataMapperTest.php
  164. +78 −0 tests/Unit/Internal/Module/Configuration/DataObject/EnvironmentConfigurationTest.php
  165. +85 −0 tests/Unit/Internal/Module/Configuration/DataObject/ModuleConfigurationTest.php
  166. +88 −0 tests/Unit/Internal/Module/Configuration/DataObject/ProjectConfigurationTest.php
  167. +82 −0 tests/Unit/Internal/Module/Configuration/DataObject/ShopConfigurationTest.php
  168. +50 −0 tests/Unit/Internal/Module/MetaData/DataMapper/MetaDataMapperTest.php
  169. +123 −0 tests/Unit/Internal/Module/MetaData/Service/MetaDataNormalizerTest.php
  170. +220 −0 tests/Unit/Internal/Module/MetaData/Service/MetaDataProviderTest.php
  171. +103 −0 tests/Unit/Internal/Module/MetaData/Service/MetaDataSchemataProviderTest.php
  172. +231 −0 tests/Unit/Internal/Module/MetaData/Validator/MetaDataValidatorTest.php
  173. +140 −0 tests/Unit/Internal/Module/Setup/Handler/ClassExtensionsModuleSettingHandlerTest.php
  174. +186 −0 tests/Unit/Internal/Module/Setup/Handler/ControllersModuleSettingHandlerTest.php
  175. +194 −0 tests/Unit/Internal/Module/Setup/Handler/ShopConfigurationModuleSettingHandlerTest.php
  176. +140 −0 tests/Unit/Internal/Module/Setup/Handler/ShopModuleSettingModuleSettingHandlerTest.php
  177. +131 −0 tests/Unit/Internal/Module/Setup/Handler/TemplateBlockModuleSettingHandlerTest.php
  178. +124 −0 tests/Unit/Internal/Module/Setup/Service/ActiveClassExtensionChainResolverTest.php
  179. +62 −0 tests/Unit/Internal/Module/Setup/Service/ModuleActivationServiceTest.php
  180. +112 −0 tests/Unit/Internal/Module/Setup/Service/ModuleSettingsHandlingServiceTest.php
  181. +131 −0 tests/Unit/Internal/Module/Setup/Validator/ClassExtensionsModuleSettingValidatorTest.php
  182. +148 −0 tests/Unit/Internal/Module/Setup/Validator/ControllersModuleSettingValidatorTest.php
  183. +110 −0 tests/Unit/Internal/Module/Setup/Validator/EventsModuleSettingValidatorTest.php
  184. +180 −0 tests/Unit/Internal/Module/Setup/Validator/SmartyPluginDirectoriesModuleSettingValidatorTest.php
  185. +48 −0 tests/Unit/Internal/Module/ShopModuleSetting/ShopModuleSettingDaoTest.php
  186. +68 −0 tests/Unit/Internal/Module/State/ModuleStateServiceTest.php
  187. +0 −119 tests/Unit/Internal/ProjectDIConfig/Service/ShopActivationServiceTest.php
  188. +0 −4 tests/Unit/Internal/ProjectDIConfig/TestModule/OtherService.php
@@ -94,6 +94,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- New command to activate module.
- New command to deactivate module.
- Module configuration:
- option `activeModules` in table oxconfig in order to determine the currently active modules
- Events:
- `\OxidEsales\EshopCommunity\Internal\Module\MetaData\Event\BadMetaDataFoundEvent`
- `\OxidEsales\EshopCommunity\Internal\Module\Setup\Event\BeforeModuleDeactivationEvent`
- `\OxidEsales\EshopCommunity\Internal\Module\Setup\Event\FinalizingModuleActivationEvent`
- `\OxidEsales\EshopCommunity\Internal\Module\Setup\Event\FinalizingModuleDeactivationEvent`
### Changed
- category_main form layout improvements [PR-585](https://github.com/OXID-eSales/oxideshop_ce/pull/585)
- Split config parameter initialization from application initialization [PR-628](https://github.com/OXID-eSales/oxideshop_ce/pull/628)
@@ -18,6 +18,7 @@
"psr/container": "1.0.*",
"symfony/event-dispatcher": "^3.4",
"symfony/dependency-injection": "^3.4",
"symfony/lock": "^3.4",
"symfony/console": "^v3.4.15",
"webmozart/path-util": "^2.3"
},
@@ -18,8 +18,7 @@
use OxidEsales\Eshop\Core\Module\Module as EshopModule;
use OxidEsales\Eshop\Core\Module\ModuleSmartyPluginDirectoryValidator as EshopModuleSmartyPluginDirectoryValidator;
use OxidEsales\EshopCommunity\Internal\Application\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\ProjectDIConfig\Service\ShopActivationServiceInterface;
use OxidEsales\Facts\Facts;
use OxidEsales\EshopCommunity\Internal\Module\Setup\Service\ModuleServicesActivationServiceInterface;
/**
* Modules installer class.
@@ -142,19 +141,19 @@ public function activate(\OxidEsales\Eshop\Core\Module\Module $module)
*/
private function activateShopAwareServices(\OxidEsales\Eshop\Core\Module\Module $module)
{
/** @var ShopActivationServiceInterface $shopActivationService */
$shopActivationService = ContainerFactory::getInstance()->getContainer()->get(ShopActivationServiceInterface::class);
$shopActivationService->activateServicesForShops($module->getModuleFullPath(), [Registry::getConfig()->getShopId()]);
/** @var ModuleServicesActivationServiceInterface $shopActivationService */
$shopActivationService = ContainerFactory::getInstance()->getContainer()->get(ModuleServicesActivationServiceInterface::class);
$shopActivationService->activateModuleServices($module->getId(), Registry::getConfig()->getShopId());
}
/**
* @param EshopModule $module
*/
private function deactivateShopAwareServices(\OxidEsales\Eshop\Core\Module\Module $module)
{
/** @var ShopActivationServiceInterface $shopActivationService */
$shopActivationService = ContainerFactory::getInstance()->getContainer()->get(ShopActivationServiceInterface::class);
$shopActivationService->deactivateServicesForShops($module->getModuleFullPath(), [Registry::getConfig()->getShopId()]);
/** @var ModuleServicesActivationServiceInterface $shopActivationService */
$shopActivationService = ContainerFactory::getInstance()->getContainer()->get(ModuleServicesActivationServiceInterface::class);
$shopActivationService->deactivateModuleServices($module->getId(), Registry::getConfig()->getShopId());
}
/**
@@ -0,0 +1,149 @@
<?php
declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
namespace OxidEsales\EshopCommunity\Internal\Adapter\Configuration\Dao;
use OxidEsales\EshopCommunity\Internal\Adapter\Configuration\DataObject\ShopConfigurationSetting;
use OxidEsales\EshopCommunity\Internal\Adapter\Configuration\Service\ShopSettingEncoderInterface;
use OxidEsales\EshopCommunity\Internal\Adapter\ShopAdapterInterface;
use OxidEsales\EshopCommunity\Internal\Common\Database\QueryBuilderFactoryInterface;
use OxidEsales\EshopCommunity\Internal\Common\Exception\EntryDoesNotExistDaoException;
use OxidEsales\EshopCommunity\Internal\Utility\ContextInterface;
/**
* @internal
*/
class ShopConfigurationSettingDao implements ShopConfigurationSettingDaoInterface
{
/**
* @var QueryBuilderFactoryInterface
*/
private $queryBuilderFactory;
/**
* @var ContextInterface
*/
private $context;
/**
* @var ShopSettingEncoderInterface
*/
private $shopSettingEncoder;
/**
* @var ShopAdapterInterface
*/
private $shopAdapter;
/**
* ShopModuleSettingDao constructor.
* @param QueryBuilderFactoryInterface $queryBuilderFactory
* @param ContextInterface $context
* @param ShopSettingEncoderInterface $shopSettingEncoder
* @param ShopAdapterInterface $shopAdapter
*/
public function __construct(
QueryBuilderFactoryInterface $queryBuilderFactory,
ContextInterface $context,
ShopSettingEncoderInterface $shopSettingEncoder,
ShopAdapterInterface $shopAdapter
) {
$this->queryBuilderFactory = $queryBuilderFactory;
$this->context = $context;
$this->shopSettingEncoder = $shopSettingEncoder;
$this->shopAdapter = $shopAdapter;
}
/**
* @param ShopConfigurationSetting $shopConfigurationSetting
*/
public function save(ShopConfigurationSetting $shopConfigurationSetting)
{
$this->delete($shopConfigurationSetting);
$queryBuilder = $this->queryBuilderFactory->create();
$queryBuilder
->insert('oxconfig')
->values([
'oxid' => ':id',
'oxshopid' => ':shopId',
'oxvarname' => ':name',
'oxvartype' => ':type',
'oxvarvalue' => 'encode(:value, :key)',
])
->setParameters([
'id' => $this->shopAdapter->generateUniqueId(),
'shopId' => $shopConfigurationSetting->getShopId(),
'name' => $shopConfigurationSetting->getName(),
'type' => $shopConfigurationSetting->getType(),
'value' => $this->shopSettingEncoder->encode(
$shopConfigurationSetting->getType(),
$shopConfigurationSetting->getValue()
),
'key' => $this->context->getConfigurationEncryptionKey(),
]);
$queryBuilder->execute();
}
/**
* @param string $name
* @param int $shopId
* @return ShopConfigurationSetting
* @throws EntryDoesNotExistDaoException
*/
public function get(string $name, int $shopId): ShopConfigurationSetting
{
$queryBuilder = $this->queryBuilderFactory->create();
$queryBuilder
->select('decode(oxvarvalue, :key) as value, oxvartype as type, oxvarname as name')
->from('oxconfig')
->where('oxshopid = :shopId')
->andWhere('oxvarname = :name')
->andWhere('oxmodule = ""')
->setParameters([
'shopId' => $shopId,
'name' => $name,
'key' => $this->context->getConfigurationEncryptionKey(),
]);
$result = $queryBuilder->execute()->fetch();
if (false === $result) {
throw new EntryDoesNotExistDaoException();
}
$setting = new ShopConfigurationSetting();
$setting
->setName($name)
->setValue($this->shopSettingEncoder->decode($result['type'], $result['value']))
->setShopId($shopId)
->setType($result['type']);
return $setting;
}
/**
* @param ShopConfigurationSetting $setting
*/
public function delete(ShopConfigurationSetting $setting)
{
$queryBuilder = $this->queryBuilderFactory->create();
$queryBuilder
->delete('oxconfig')
->where('oxshopid = :shopId')
->andWhere('oxvarname = :name')
->andWhere('oxmodule = ""')
->setParameters([
'shopId' => $setting->getShopId(),
'name' => $setting->getName(),
]);
$queryBuilder->execute();
}
}
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
namespace OxidEsales\EshopCommunity\Internal\Adapter\Configuration\Dao;
use OxidEsales\EshopCommunity\Internal\Adapter\Configuration\DataObject\ShopConfigurationSetting;
use OxidEsales\EshopCommunity\Internal\Common\Exception\EntryDoesNotExistDaoException;
/**
* @internal
*/
interface ShopConfigurationSettingDaoInterface
{
/**
* @param ShopConfigurationSetting $shopConfigurationSetting
*/
public function save(ShopConfigurationSetting $shopConfigurationSetting);
/**
* @param string $name
* @param int $shopId
* @return ShopConfigurationSetting
*
* @throws EntryDoesNotExistDaoException
*/
public function get(string $name, int $shopId): ShopConfigurationSetting;
/**
* @param ShopConfigurationSetting $setting
*/
public function delete(ShopConfigurationSetting $setting);
}
@@ -0,0 +1,118 @@
<?php
declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
namespace OxidEsales\EshopCommunity\Internal\Adapter\Configuration\DataObject;
/**
* @internal
*/
class ShopConfigurationSetting
{
const MODULE_CLASS_EXTENSIONS = 'aModuleExtensions';
const MODULE_CLASS_EXTENSIONS_CHAIN = 'aModules';
const MODULE_CONTROLLERS = 'aModuleControllers';
const MODULE_VERSIONS = 'aModuleVersions';
const MODULE_PATHS = 'aModulePaths';
const MODULE_TEMPLATES = 'aModuleTemplates';
const MODULE_SMARTY_PLUGIN_DIRECTORIES = 'moduleSmartyPluginDirectories';
const MODULE_EVENTS = 'aModuleEvents';
const ACTIVE_MODULES = 'activeModules';
/**
* @var int
*/
private $shopId;
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $type;
/**
* @var mixed
*/
private $value;
/**
* @return int
*/
public function getShopId(): int
{
return $this->shopId;
}
/**
* @param int $shopId
* @return ShopConfigurationSetting
*/
public function setShopId(int $shopId): ShopConfigurationSetting
{
$this->shopId = $shopId;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return ShopConfigurationSetting
*/
public function setName(string $name): ShopConfigurationSetting
{
$this->name = $name;
return $this;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
* @return ShopConfigurationSetting
*/
public function setType(string $type): ShopConfigurationSetting
{
$this->type = $type;
return $this;
}
/**
* @return mixed
*/
public function getValue()
{
return $this->value;
}
/**
* @param mixed $value
* @return ShopConfigurationSetting
*/
public function setValue($value): ShopConfigurationSetting
{
$this->value = $value;
return $this;
}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
namespace OxidEsales\EshopCommunity\Internal\Adapter\Configuration\DataObject;
/**
* @internal
*/
class ShopSettingType
{
const BOOLEAN = 'bool';
const ARRAY = 'arr';
const ASSOCIATIVE_ARRAY = 'aarr';
}
Oops, something went wrong.

0 comments on commit e7ce86f

Please sign in to comment.