Permalink
Browse files

Merge branch 'b-6.x'

  • Loading branch information...
MantasVaitkunas committed Dec 6, 2018
2 parents 8f3a22e + 2dc3604 commit 541df01e202a08bedabc154fa3f25ace7412f550
Showing with 1,140 additions and 147 deletions.
  1. +5 −1 CHANGELOG.md
  2. +43 −0 bin/oe-console
  3. +3 −1 composer.json
  4. +12 −0 source/Internal/Adapter/ShopAdapter.php
  5. +5 −0 source/Internal/Adapter/ShopAdapterInterface.php
  6. +5 −7 source/Internal/Application/ContainerBuilder.php
  7. +3 −4 source/Internal/Application/ContainerFactory.php
  8. +3 −3 source/Internal/Application/Dao/ContainerAwareProjectYamlDao.php
  9. +6 −10 source/Internal/Application/Dao/ProjectYamlDao.php
  10. +0 −1 source/Internal/Application/Events/AbstractShopAwareEventSubscriber.php
  11. +1 −3 source/Internal/Application/Events/ShopAwareEventDispatcher.php
  12. +1 −3 source/Internal/Application/Events/ShopAwareInterface.php
  13. +0 −1 source/Internal/Application/Events/ShopAwareServiceTrait.php
  14. +3 −5 source/Internal/Application/Service/ProjectYamlImportService.php
  15. +1 −1 source/Internal/Application/Service/ProjectYamlImportServiceInterface.php
  16. +2 −0 source/Internal/Application/services.yaml
  17. +19 −0 source/Internal/Console/AbstractShopAwareCommand.php
  18. +19 −0 source/Internal/Console/CommandsProvider/CommandsProviderInterface.php
  19. +76 −0 source/Internal/Console/CommandsProvider/ServicesCommandsProvider.php
  20. +49 −0 source/Internal/Console/ConsoleCommandPass.php
  21. +54 −0 source/Internal/Console/Executor.php
  22. +23 −0 source/Internal/Console/ExecutorInterface.php
  23. +40 −0 source/Internal/Console/services.yaml
  24. +87 −0 source/Internal/Module/Command/ModuleActivateCommand.php
  25. +86 −0 source/Internal/Module/Command/ModuleDeactivateCommand.php
  26. +13 −0 source/Internal/Module/Command/services.yaml
  27. +0 −32 source/Internal/Utility/Context.php
  28. +0 −10 source/Internal/Utility/ContextInterface.php
  29. +50 −0 source/Internal/Utility/FactsContext.php
  30. +24 −0 source/Internal/Utility/FactsContextInterface.php
  31. +4 −4 source/Internal/Utility/services.yaml
  32. +28 −37 tests/Integration/Internal/Application/Dao/ProjectYamlDaoTest.php
  33. +0 −1 tests/Integration/Internal/Application/Dao/project.yaml
  34. +11 −11 tests/Integration/Internal/Application/Events/ShopAwareEventsTest.php
  35. +2 −6 tests/Integration/Internal/Application/Events/TestEvent.php
  36. +2 −6 tests/Integration/Internal/Application/Events/TestEventSubscriber.php
  37. +37 −0 tests/Integration/Internal/Console/ConsoleTrait.php
  38. +77 −0 tests/Integration/Internal/Console/ExecutorTest.php
  39. +24 −0 tests/Integration/Internal/Console/Fixtures/TestCommand.php
  40. +20 −0 tests/Integration/Internal/Console/Fixtures/project.yaml
  41. +33 −0 tests/Integration/Internal/ContainerTrait.php
  42. +19 −0 tests/Integration/Internal/Module/Command/Fixtures/modules/testmodule/metadata.php
  43. +62 −0 tests/Integration/Internal/Module/Command/ModuleActivateCommandTest.php
  44. +46 −0 tests/Integration/Internal/Module/Command/ModuleCommandsTestCase.php
  45. +78 −0 tests/Integration/Internal/Module/Command/ModuleDeactivateCommandTest.php
  46. +64 −0 tests/Unit/Internal/Console/CommandsProvider/ServicesCommandsProviderTest.php
@@ -88,7 +88,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- New blocks:
- `admin_module_sortlist` in `admin/tpl/module_sortlist.tpl` [PR-534](https://github.com/OXID-eSales/oxideshop_ce/pull/534)
- Log missing translations [PR-520](https://github.com/OXID-eSales/oxideshop_ce/pull/520)
- Introduce new feature - reset category filter [0002046](https://bugs.oxid-esales.com/view.php?id=2046)
- New features:
- Reset category filter [0002046](https://bugs.oxid-esales.com/view.php?id=2046)
- OXID eShop console, which allows to register custom commands for modules and for components via `services.yaml`.
- New command to activate module.
- New command to deactivate module.
### Changed
- category_main form layout improvements [PR-585](https://github.com/OXID-eSales/oxideshop_ce/pull/585)
@@ -0,0 +1,43 @@
#!/usr/bin/env php
<?php
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
use OxidEsales\EshopEnterprise\Internal\Console\CommandEventSubscriber;
use OxidEsales\Facts\Facts;
use Symfony\Component\Console\Input\ArgvInput;
use Webmozart\PathUtil\Path;
$autoloadFileExist = false;
$autoloadFiles = [
__DIR__ . '/../vendor/autoload.php',
__DIR__ . '/../../vendor/autoload.php',
__DIR__ . '/../../../vendor/autoload.php',
__DIR__ . '/../../../../vendor/autoload.php',
];
foreach ($autoloadFiles as $autoloadFile) {
if (file_exists($autoloadFile)) {
require_once $autoloadFile;
$autoloadFileExist = true;
break;
}
}
if (!$autoloadFileExist) {
exit("autoload.php file was not found!");
}
$shopId = (int) (new ArgvInput())->getParameterOption(
'--'.CommandEventSubscriber::SHOP_ID_PARAMETER_OPTION_NAME,
0
);
if ($shopId !== 0) {
$_POST['shp'] = $shopId;
}
$bootstrapFilePath = Path::join((new Facts())->getSourcePath(), 'bootstrap.php');
require_once $bootstrapFilePath;
$factory = \OxidEsales\EshopCommunity\Internal\Application\ContainerFactory::getInstance();
$factory->getContainer()->get(OxidEsales\EshopCommunity\Internal\Console\ExecutorInterface::class)->execute();
@@ -17,7 +17,8 @@
"monolog/monolog": "^v1.23.0",
"psr/container": "1.0.*",
"symfony/event-dispatcher": "^3.4",
"symfony/dependency-injection": "^3.4"
"symfony/dependency-injection": "^3.4",
"symfony/console": "^v3.4.15"
},
"require-dev": {
"oxid-esales/flow-theme": "^v3.0.2",
@@ -45,6 +46,7 @@
},
"minimum-stability": "dev",
"prefer-stable": true,
"bin": ["bin/oe-console"],
"scripts": {
"post-install-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
@@ -7,6 +7,7 @@
namespace OxidEsales\EshopCommunity\Internal\Adapter;
use OxidEsales\Eshop\Core\MailValidator;
use OxidEsales\Eshop\Core\Module\ModuleList;
use OxidEsales\Eshop\Core\Registry;
/**
@@ -35,4 +36,15 @@ public function translateString($string)
return $lang->translateString($string);
}
/**
* @return array
*/
public function getModules()
{
$moduleList = oxNew(ModuleList::class);
$moduleList->getModulesFromDir(Registry::getConfig()->getModulesDir());
return $moduleList->getList();
}
}
@@ -22,4 +22,9 @@ public function isValidEmail($email);
* @return string
*/
public function translateString($string);
/**
* @return array
*/
public function getModules();
}
@@ -1,17 +1,15 @@
<?php
declare(strict_types=1);
<?php declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/
namespace OxidEsales\EshopCommunity\Internal\Application;
use OxidEsales\EshopCommunity\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Console\ConsoleCommandPass;
use OxidEsales\EshopCommunity\Internal\Application\Dao\ProjectYamlDao;
use OxidEsales\EshopCommunity\Internal\Application\Service\ProjectYamlImportService;
use OxidEsales\EshopCommunity\Internal\Utility\Context;
use OxidEsales\EshopCommunity\Internal\Utility\FactsContext;
use OxidEsales\Facts\Facts;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Container;
@@ -52,6 +50,7 @@ public function getContainer(): Container
{
$symfonyContainer = new SymfonyContainerBuilder();
$symfonyContainer->addCompilerPass(new RegisterListenersPass());
$symfonyContainer->addCompilerPass(new ConsoleCommandPass());
$this->loadServiceFiles($symfonyContainer);
if ($this->facts->isProfessional()) {
$this->loadEditionServices($symfonyContainer, $this->facts->getProfessionalEditionRootPath());
@@ -100,8 +99,7 @@ private function loadProjectServices(SymfonyContainerBuilder $symfonyContainer)
*/
private function cleanupProjectYaml()
{
$context = new Context(Registry::getConfig());
$projectYamlDao = new ProjectYamlDao($context);
$projectYamlDao = new ProjectYamlDao(new FactsContext());
$yamlImportService = new ProjectYamlImportService($projectYamlDao);
$yamlImportService->removeNonExistingImports();
}
@@ -7,9 +7,8 @@
namespace OxidEsales\EshopCommunity\Internal\Application;
use OxidEsales\Eshop\Core\Registry;
use OxidEsales\EshopCommunity\Internal\Utility\FactsContext;
use OxidEsales\Facts\Facts;
use OxidEsales\EshopCommunity\Internal\Utility\Context;
use Psr\Container\ContainerInterface;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
@@ -103,8 +102,8 @@ private function saveContainerToCache($cachefile)
*/
private static function getCacheFilePath()
{
$context = new Context(Registry::getConfig());
return $context->getContainerCacheFile();
$context = new FactsContext();
return $context->getContainerCacheFilePath();
}
/**
@@ -9,7 +9,7 @@
use OxidEsales\EshopCommunity\Internal\Application\Events\ProjectYamlChangedEvent;
use OxidEsales\EshopCommunity\Internal\Application\DataObject\DIConfigWrapper;
use OxidEsales\EshopCommunity\Internal\Utility\ContextInterface;
use OxidEsales\EshopCommunity\Internal\Utility\FactsContextInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
@@ -25,10 +25,10 @@ class ContainerAwareProjectYamlDao extends ProjectYamlDao
/**
* ProjectYamlDao constructor.
*
* @param ContextInterface $context
* @param FactsContextInterface $context
* @param EventDispatcherInterface $eventDispatcher
*/
public function __construct(ContextInterface $context, EventDispatcherInterface $eventDispatcher)
public function __construct(FactsContextInterface $context, EventDispatcherInterface $eventDispatcher)
{
parent::__construct($context);
$this->eventDispatcher = $eventDispatcher;
@@ -1,5 +1,4 @@
<?php declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
@@ -9,7 +8,7 @@
use OxidEsales\EshopCommunity\Internal\Application\Events\ProjectYamlChangedEvent;
use OxidEsales\EshopCommunity\Internal\Application\DataObject\DIConfigWrapper;
use OxidEsales\EshopCommunity\Internal\Utility\ContextInterface;
use OxidEsales\EshopCommunity\Internal\Utility\FactsContextInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Yaml\Yaml;
@@ -18,20 +17,17 @@
*/
class ProjectYamlDao implements ProjectYamlDaoInterface
{
const PROJECT_FILE_NAME = 'project.yaml';
/**
* @var ContextInterface $context
* @var FactsContextInterface $context
*/
private $context;
/**
* ProjectYamlDao constructor.
*
* @param ContextInterface $context
* @param FactsContextInterface $context
*/
public function __construct(ContextInterface $context)
public function __construct(FactsContextInterface $context)
{
$this->context = $context;
}
@@ -55,7 +51,7 @@ public function saveProjectConfigFile(DIConfigWrapper $config)
/**
* @param string $path
*
* @return array
* @return DIConfigWrapper
*/
public function loadDIConfigFile(string $path): DIConfigWrapper
{
@@ -73,6 +69,6 @@ public function loadDIConfigFile(string $path): DIConfigWrapper
*/
private function getProjectFileName(): string
{
return $this->context->getShopDir() . DIRECTORY_SEPARATOR . self::PROJECT_FILE_NAME;
return $this->context->getSourcePath() . DIRECTORY_SEPARATOR . self::PROJECT_FILE_NAME;
}
}
@@ -7,7 +7,6 @@
namespace OxidEsales\EshopCommunity\Internal\Application\Events;
use OxidEsales\EshopCommunity\Internal\Utility\ContextInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
@@ -1,6 +1,4 @@
<?php
declare(strict_types=1);
<?php declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
@@ -1,6 +1,4 @@
<?php
declare(strict_types=1);
<?php declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
@@ -1,5 +1,4 @@
<?php declare(strict_types=1);
/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
@@ -8,14 +8,12 @@
namespace OxidEsales\EshopCommunity\Internal\Application\Service;
use OxidEsales\EshopCommunity\Internal\Application\Dao\ProjectYamlDaoInterface;
use OxidEsales\EshopCommunity\Internal\Application\Service\ProjectYamlImportServiceInterface;
/**
* Class ProjectYamlImportService
*/
class ProjectYamlImportService implements ProjectYamlImportServiceInterface
{
/**
* @var ProjectYamlDaoInterface
*/
@@ -24,11 +22,11 @@ class ProjectYamlImportService implements ProjectYamlImportServiceInterface
/**
* ProjectYamlImportService constructor.
*
* @param ProjectYamlDaoInterface $dao
* @param ProjectYamlDaoInterface $projectYamlDao
*/
public function __construct(ProjectYamlDaoInterface $dao)
public function __construct(ProjectYamlDaoInterface $projectYamlDao)
{
$this->projectYamlDao = $dao;
$this->projectYamlDao = $projectYamlDao;
}
/**
@@ -8,7 +8,7 @@
namespace OxidEsales\EshopCommunity\Internal\Application\Service;
/**
* Class ProjectYamlImportService
* @internal
*/
interface ProjectYamlImportServiceInterface
{
@@ -9,4 +9,6 @@ imports:
- { resource: ../Form/services.yaml }
- { resource: ../Adapter/services.yaml }
- { resource: ../ProjectDIConfig/services.yaml }
- { resource: ../Console/services.yaml }
- { resource: ../Module/Command/services.yaml }
@@ -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\Console;
use OxidEsales\EshopCommunity\Internal\Application\Events\ShopAwareInterface;
use OxidEsales\EshopCommunity\Internal\Application\Events\ShopAwareServiceTrait;
use Symfony\Component\Console\Command\Command;
/**
* Class is being used to detect if command active for active shop.
*/
abstract class AbstractShopAwareCommand extends Command implements ShopAwareInterface
{
use ShopAwareServiceTrait;
}
@@ -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\Console\CommandsProvider;
/**
* Provides commands classes.
* @internal
*/
interface CommandsProviderInterface
{
/**
* @return array
*/
public function getCommands(): array;
}
Oops, something went wrong.

0 comments on commit 541df01

Please sign in to comment.