Skip to content
Permalink
Browse files

OXDEV-1287 Split project configuration file into one file per shop

  • Loading branch information...
iegupov committed Jun 28, 2019
1 parent c4a181f commit 905527d81bb26723ea9cc023b0b710c83d5281fa
Showing with 985 additions and 682 deletions.
  1. +2 −2 source/Internal/Application/Utility/BasicContext.php
  2. +1 −1 source/Internal/Application/Utility/BasicContextInterface.php
  3. +15 −0 source/Internal/Common/Storage/FileStorageFactoryInterface.php
  4. +56 −0 source/Internal/Common/Storage/YamlFileStorageFactory.php
  5. +4 −0 source/Internal/Common/bootstrap-services.yaml
  6. +13 −12 source/Internal/Module/Command/ModuleActivateCommand.php
  7. +17 −12 source/Internal/Module/Command/ModuleDeactivateCommand.php
  8. +14 −19 source/Internal/Module/Configuration/Bridge/ShopConfigurationDaoBridge.php
  9. +40 −0 source/Internal/Module/Configuration/Cache/ClassPropertyShopConfigurationCache.php
  10. +23 −0 source/Internal/Module/Configuration/Cache/ShopConfigurationCache.php
  11. +13 −18 source/Internal/Module/Configuration/Dao/ModuleConfigurationDao.php
  12. +96 −31 source/Internal/Module/Configuration/Dao/ProjectConfigurationDao.php
  13. +2 −2 source/Internal/Module/Configuration/Dao/ProjectConfigurationDaoInterface.php
  14. +203 −0 source/Internal/Module/Configuration/Dao/ShopConfigurationDao.php
  15. +35 −0 source/Internal/Module/Configuration/Dao/ShopConfigurationDaoInterface.php
  16. +86 −98 source/Internal/Module/Configuration/Definition/TreeBuilderFactory.php
  17. +10 −13 source/Internal/Module/Configuration/bootstrap-services.yaml
  18. +1 −1 source/Internal/Module/Install/Service/ModuleConfigurationInstaller.php
  19. +1 −1 source/Internal/Module/Install/Service/ProjectConfigurationGenerator.php
  20. +7 −19 source/Internal/Module/Setup/Service/ActiveClassExtensionChainResolver.php
  21. +0 −23 tests/Integration/Internal/Module/Command/InstallModuleConfigurationCommandTest.php
  22. +6 −14 tests/Integration/Internal/Module/Configuration/Dao/ModuleConfigurationDaoTest.php
  23. +133 −73 tests/Integration/Internal/Module/Configuration/Dao/ProjectConfigurationDaoTest.php
  24. +112 −0 tests/Integration/Internal/Module/Configuration/Dao/ShopConfigurationDaoTest.php
  25. +1 −1 tests/Integration/Internal/Module/Install/Service/ModuleConfigurationInstallerTest.php
  26. +11 −56 tests/Integration/Internal/Module/Setup/ModuleEventsTest.php
  27. +3 −11 tests/Integration/Internal/Module/Setup/Service/ModuleActivationServiceTest.php
  28. +6 −15 tests/Integration/Internal/TestContainerFactory.php
  29. +1 −1 tests/Integration/Modules/ModuleActivationFirstTest.php
  30. +1 −1 tests/Integration/Modules/ModuleDeactivationTest.php
  31. +1 −1 tests/Integration/Modules/ModuleRemoveTest.php
  32. +20 −4 tests/Unit/Internal/BasicContextStub.php
  33. +44 −0 tests/Unit/Internal/Module/Configuration/Cache/ClassPropertyShopConfigurationCacheTest.php
  34. +0 −72 tests/Unit/Internal/Module/Configuration/Dao/ModuleConfigurationDaoTest.php
  35. +0 −166 tests/Unit/Internal/Module/Configuration/Dao/ProjectConfigurationDaoTest.php
  36. +1 −1 tests/Unit/Internal/Module/Install/Service/ProjectConfigurationGeneratorTest.php
  37. +6 −14 tests/Unit/Internal/Module/Setup/Service/ActiveClassExtensionChainResolverTest.php
@@ -142,9 +142,9 @@ public function getBackwardsCompatibilityClassMap(): array
/**
* @return string
*/
public function getProjectConfigurationPath(): string
public function getProjectConfigurationDirectory(): string
{
return $this->getConfigurationDirectoryPath() . 'project_configuration.yml';
return $this->getConfigurationDirectoryPath() . 'project_configuration/';
}
/**
@@ -75,7 +75,7 @@ public function getBackwardsCompatibilityClassMap(): array;
/**
* @return string
*/
public function getProjectConfigurationPath(): string;
public function getProjectConfigurationDirectory(): string;
/**
* @return string
@@ -0,0 +1,15 @@
<?php declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
namespace OxidEsales\EshopCommunity\Internal\Common\Storage;
/**
* @internal
*/
interface FileStorageFactoryInterface
{
public function create(string $filePath): ArrayStorageInterface;
}
@@ -0,0 +1,56 @@
<?php declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
namespace OxidEsales\EshopCommunity\Internal\Common\Storage;
use Symfony\Component\Config\FileLocatorInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Lock\Factory;
/**
* @internal
*/
class YamlFileStorageFactory implements FileStorageFactoryInterface
{
/**
* @var FileLocatorInterface
*/
private $fileLocator;
/**
* @var Factory
*/
private $lockFactory;
/**
* @var Filesystem
*/
private $filesystemService;
/**
* YamlFileStorageFactory constructor.
* @param FileLocatorInterface $fileLocator
* @param Factory $lockFactory
* @param Filesystem $filesystemService
*/
public function __construct(FileLocatorInterface $fileLocator, Factory $lockFactory, Filesystem $filesystemService)
{
$this->fileLocator = $fileLocator;
$this->lockFactory = $lockFactory;
$this->filesystemService = $filesystemService;
}
public function create(string $filePath): ArrayStorageInterface
{
return new YamlFileStorage(
$this->fileLocator,
$filePath,
$this->lockFactory,
$this->filesystemService
);
}
}
@@ -14,3 +14,7 @@ services:
OxidEsales\EshopCommunity\Internal\Common\FileSystem\FinderFactoryInterface:
class: OxidEsales\EshopCommunity\Internal\Common\FileSystem\FinderFactory
autowire: true

OxidEsales\EshopCommunity\Internal\Common\Storage\FileStorageFactoryInterface:
class: OxidEsales\EshopCommunity\Internal\Common\Storage\YamlFileStorageFactory
autowire: true
@@ -6,7 +6,7 @@
namespace OxidEsales\EshopCommunity\Internal\Module\Command;
use OxidEsales\EshopCommunity\Internal\Module\Configuration\Dao\ProjectConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Module\Configuration\Dao\ShopConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Module\Setup\Exception\ModuleSetupException;
use OxidEsales\EshopCommunity\Internal\Module\Setup\Service\ModuleActivationServiceInterface;
use OxidEsales\EshopCommunity\Internal\Utility\ContextInterface;
@@ -29,9 +29,9 @@ class ModuleActivateCommand extends Command
/**
* @var ProjectConfigurationDaoInterface
* @var ShopConfigurationDaoInterface
*/
private $projectConfigurationDao;
private $shopConfigurationDao;
/**
* @var ContextInterface
@@ -44,18 +44,18 @@ class ModuleActivateCommand extends Command
private $moduleActivationService;
/**
* @param ProjectConfigurationDaoInterface $projectConfigurationDao
* @param ShopConfigurationDaoInterface $shopConfigurationDao
* @param ContextInterface $context
* @param ModuleActivationServiceInterface $moduleActivationService
*/
public function __construct(
ProjectConfigurationDaoInterface $projectConfigurationDao,
ShopConfigurationDaoInterface $shopConfigurationDao,
ContextInterface $context,
ModuleActivationServiceInterface $moduleActivationService
) {
parent::__construct(null);
$this->projectConfigurationDao = $projectConfigurationDao;
$this->shopConfigurationDao = $shopConfigurationDao;
$this->context = $context;
$this->moduleActivationService = $moduleActivationService;
}
@@ -96,7 +96,9 @@ protected function activateModule(OutputInterface $output, string $moduleId)
$this->moduleActivationService->activate($moduleId, $this->context->getCurrentShopId());
$output->writeLn('<info>'.sprintf(static::MESSAGE_MODULE_ACTIVATED, $moduleId).'</info>');
} catch (ModuleSetupException $exception) {
$output->writeLn('<info>'.sprintf(static::MESSAGE_MODULE_ALREADY_ACTIVE, $moduleId).'</info>');
$output->writeLn(
'<info>'.sprintf(static::MESSAGE_MODULE_ALREADY_ACTIVE, $moduleId).'</info>'
);
}
}
@@ -106,11 +108,10 @@ protected function activateModule(OutputInterface $output, string $moduleId)
*/
private function isInstalled(string $moduleId): bool
{
$shopConfiguration = $this
->projectConfigurationDao
->getConfiguration()
->getEnvironmentConfiguration($this->context->getEnvironment())
->getShopConfiguration($this->context->getCurrentShopId());
$shopConfiguration = $this->shopConfigurationDao->get(
$this->context->getCurrentShopId(),
$this->context->getEnvironment()
);
return $shopConfiguration->hasModuleConfiguration($moduleId);
}
@@ -6,7 +6,7 @@
namespace OxidEsales\EshopCommunity\Internal\Module\Command;
use OxidEsales\EshopCommunity\Internal\Module\Configuration\Dao\ProjectConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Module\Configuration\Dao\ShopConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Module\Setup\Exception\ModuleSetupException;
use OxidEsales\EshopCommunity\Internal\Module\Setup\Service\ModuleActivationServiceInterface;
use OxidEsales\EshopCommunity\Internal\Utility\ContextInterface;
@@ -30,9 +30,9 @@ class ModuleDeactivateCommand extends Command
const ARGUMENT_MODULE_ID = 'module-id';
/**
* @var ProjectConfigurationDaoInterface
* @var ShopConfigurationDaoInterface
*/
private $projectConfigurationDao;
private $shopConfigurationDao;
/**
* @var ContextInterface
@@ -45,18 +45,18 @@ class ModuleDeactivateCommand extends Command
private $moduleActivationService;
/**
* @param ProjectConfigurationDaoInterface $projectConfigurationDao
* @param ShopConfigurationDaoInterface $shopConfigurationDao
* @param ContextInterface $context
* @param ModuleActivationServiceInterface $moduleActivationService
*/
public function __construct(
ProjectConfigurationDaoInterface $projectConfigurationDao,
ShopConfigurationDaoInterface $shopConfigurationDao,
ContextInterface $context,
ModuleActivationServiceInterface $moduleActivationService
) {
parent::__construct(null);
$this->projectConfigurationDao = $projectConfigurationDao;
$this->shopConfigurationDao = $shopConfigurationDao;
$this->context = $context;
$this->moduleActivationService = $moduleActivationService;
}
@@ -94,9 +94,13 @@ protected function deactivateModule(OutputInterface $output, string $moduleId)
{
try {
$this->moduleActivationService->deactivate($moduleId, $this->context->getCurrentShopId());
$output->writeLn('<info>' . sprintf(static::MESSAGE_MODULE_DEACTIVATED, $moduleId) . '</info>');
$output->writeLn(
'<info>' . sprintf(static::MESSAGE_MODULE_DEACTIVATED, $moduleId) . '</info>'
);
} catch (ModuleSetupException $exception) {
$output->writeLn('<info>' . sprintf(static::MESSAGE_NOT_POSSIBLE_TO_DEACTIVATE, $moduleId) . '</info>');
$output->writeLn(
'<info>' . sprintf(static::MESSAGE_NOT_POSSIBLE_TO_DEACTIVATE, $moduleId) . '</info>'
);
}
}
@@ -107,10 +111,11 @@ protected function deactivateModule(OutputInterface $output, string $moduleId)
private function isInstalled(string $moduleId): bool
{
$shopConfiguration = $this
->projectConfigurationDao
->getConfiguration()
->getEnvironmentConfiguration($this->context->getEnvironment())
->getShopConfiguration($this->context->getCurrentShopId());
->shopConfigurationDao
->get(
$this->context->getCurrentShopId(),
$this->context->getEnvironment()
);
return $shopConfiguration->hasModuleConfiguration($moduleId);
}
@@ -6,7 +6,7 @@
namespace OxidEsales\EshopCommunity\Internal\Module\Configuration\Bridge;
use OxidEsales\EshopCommunity\Internal\Module\Configuration\Dao\ProjectConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Module\Configuration\Dao\ShopConfigurationDaoInterface;
use OxidEsales\EshopCommunity\Internal\Module\Configuration\DataObject\ShopConfiguration;
use OxidEsales\EshopCommunity\Internal\Utility\ContextInterface;
@@ -21,46 +21,41 @@ class ShopConfigurationDaoBridge implements ShopConfigurationDaoBridgeInterface
private $context;
/**
* @var ProjectConfigurationDaoInterface
* @var ShopConfigurationDaoInterface
*/
private $projectConfigurationDao;
private $shopConfigurationDao;
/**
* ShopConfigurationDaoBridge constructor.
* @param ContextInterface $context
* @param ProjectConfigurationDaoInterface $projectConfigurationDao
* @param ContextInterface $context
* @param ShopConfigurationDaoInterface $shopConfigurationDao
*/
public function __construct(ContextInterface $context, ProjectConfigurationDaoInterface $projectConfigurationDao)
public function __construct(ContextInterface $context, ShopConfigurationDaoInterface $shopConfigurationDao)
{
$this->context = $context;
$this->projectConfigurationDao = $projectConfigurationDao;
$this->shopConfigurationDao = $shopConfigurationDao;
}
/**
* @return ShopConfiguration
*/
public function get(): ShopConfiguration
{
return $this
->projectConfigurationDao
->getConfiguration()
->getEnvironmentConfiguration($this->context->getEnvironment())
->getShopConfiguration($this->context->getCurrentShopId());
return $this->shopConfigurationDao->get(
$this->context->getCurrentShopId(),
$this->context->getEnvironment()
);
}
/**
* @param ShopConfiguration $shopConfiguration
*/
public function save(ShopConfiguration $shopConfiguration)
{
$projectConfiguration = $this->projectConfigurationDao->getConfiguration();
$environmentConfiguration = $projectConfiguration->getEnvironmentConfiguration($this->context->getEnvironment());
$environmentConfiguration->addShopConfiguration(
$this->shopConfigurationDao->save(
$shopConfiguration,
$this->context->getCurrentShopId(),
$shopConfiguration
$this->context->getEnvironment()
);
$this->projectConfigurationDao->persistConfiguration($projectConfiguration);
}
}
@@ -0,0 +1,40 @@
<?php declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
namespace OxidEsales\EshopCommunity\Internal\Module\Configuration\Cache;
use OxidEsales\EshopCommunity\Internal\Module\Configuration\DataObject\ShopConfiguration;
/**
* @internal
*/
class ClassPropertyShopConfigurationCache implements ShopConfigurationCache
{
/**
* @var string[]
*/
private $cache;
public function put(string $environment, int $shopId, ShopConfiguration $configuration): void
{
$this->cache[$environment][$shopId] = $configuration;
}
public function get(string $environment, int $shopId): ShopConfiguration
{
return $this->cache[$environment][$shopId];
}
public function exists(string $environment, int $shopId): bool
{
return isset($this->cache[$environment][$shopId]);
}
public function evict(string $environment, int $shopId): void
{
unset($this->cache[$environment][$shopId]);
}
}
@@ -0,0 +1,23 @@
<?php declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
namespace OxidEsales\EshopCommunity\Internal\Module\Configuration\Cache;
use OxidEsales\EshopCommunity\Internal\Module\Configuration\DataObject\ShopConfiguration;
/**
* @internal
*/
interface ShopConfigurationCache
{
public function put(string $environment, int $shopId, ShopConfiguration $configuration): void;
public function get(string $environment, int $shopId): ShopConfiguration;
public function exists(string $environment, int $shopId): bool;
public function evict(string $environment, int $shopId): void;
}

0 comments on commit 905527d

Please sign in to comment.
You can’t perform that action at this time.