Skip to content

Commit 4a925e9

Browse files
committed
All command of the new oe-console adapted and made functional.
1 parent 420bf83 commit 4a925e9

29 files changed

+475
-749
lines changed

CHANGELOG.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030
- now a oxideshop component
3131
- Command `module:activate` is now `oe:module:activate`
3232
- Command `module:deactivate` is now `oe:module:deactivate`
33+
- Command `misc:phpstorm:metadata` updated to oxid namespace style and fill Module parent classes
34+
- See more [details](READY_CONVERED_TO_v6.2.md) which command refactored
3335

3436
### Removed
3537
- `oxrun.phar` use ./vendor/bin/oe-console
3638
- Command `cms:update`
37-
- Command `log:exceptionlog` the log - output has be changed
39+
- Command `log:exceptionlog` the log - output has be changed
3840
- Command `list` don't show database errors
39-
41+
- Command `misc:generate:yaml:module` oxid-esale has a new concept
42+
- Command `module:multiactivate` oxid-esale has a new concept
43+
4044

4145
## [v4.2.1] 2020-06-19
4246

@@ -74,17 +78,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7478

7579
- Option `--oxmodule` of command `misc:generate:yaml:config` can only take the module name or completely written out.
7680
`--oxmodule=module:myModule` and `--oxmodule=myModule` are same.
77-
- Rename command `misc:generate:yaml:multiset` to `misc:generate:yaml:config` to better distinguish
81+
- Rename command `misc:generate:yaml:multiset` to `misc:generate:yaml:config` to better distinguish
7882
between `yaml:modules` and `yaml:multiset`.
7983
- Find now several ways to find the oxid eshop directory.
8084

8185
### Fixed
8286

8387
- If there are errors in the DI container. It will be tried to recreate it automatically.
8488
- Modules that extend the OxidEsales\Eshop\Core\Cache\Generic\Cache class are considered.
85-
89+
8690
### Deprecated
87-
91+
8892
- command `misc:generate:yaml:multiset` was replaced by `misc:generate:yaml:config`
8993

9094
## [v4.0.0] 2019-03-24
@@ -102,7 +106,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
102106

103107
### Added
104108

105-
- There are three methods to add your own command.
109+
- There are three methods to add your own command.
106110
- new option for every command `--shopId` or `-m` select a shop for oxrun
107111
- command `cache:clear` can now clear the GenericCache and DynamicContentCache in a EE version.
108112

@@ -111,10 +115,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
111115
- When generating a module, the Composer.json file is now edited with the original classe.
112116
- oxrun can now use in EE
113117
- The file docker-compose.yml has been prepared to install an EE. You have to deposit the access data and change it to ee manuel.
114-
- Security risk: Better keep the config files outside of the public `source/` folder.
118+
- Security risk: Better keep the config files outside of the public `source/` folder.
115119
The YAML files are searched under the directory: `INSTALLATION_ROOT_PATH/oxrun_config/`. In the same level as `source/` and `vendor/` folder.
116120
- Deployment Docker. The OXID eSale source code is outside of the Container.
117-
- Now starts 2x faster. The first start will collect the command and save it as a DI container in `oxide-esale/vendor/oxideprojects/OxrunCommands.php`.
121+
- Now starts 2x faster. The first start will collect the command and save it as a DI container in `oxide-esale/vendor/oxideprojects/OxrunCommands.php`.
118122
- README.md has now a "table of content" a list of commands. And will autogenerate by travis.
119123

120124
### Fixed
@@ -128,7 +132,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
128132

129133
### Added
130134

131-
- oxrun can share his command with other cli tools like [ps:console](https://github.com/OXIDprojects/oxid-console), [oxid:console](https://github.com/OXID-eSales/oxideshop_ce/tree/b-6.x-introduce_console-OXDEV-1580)
135+
- oxrun can share his command with other cli tools like [ps:console](https://github.com/OXIDprojects/oxid-console), [oxid:console](https://github.com/OXID-eSales/oxideshop_ce/tree/b-6.x-introduce_console-OXDEV-1580)
132136

133137
### Removed
134138

READY_CONVERED_TO_v6.2.md

+25-25
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@ Commands that are successfully tested in the oxide v6.2.3.
55

66
| Command | v6.2 | Extra |
77
|------------------------------|-------------|----------------------|
8-
|`cache:clear` | [ ] | |
8+
|`cache:clear` | [x] | |
99
|`cms:update` | [removed] | Not used |
10-
|`config:get` | [ ] | |
11-
|`config:multiset` | [ ] | |
12-
|`config:set` | [ ] | |
13-
|`config:shop:get` | [ ] | |
14-
|`config:shop:set` | [ ] | |
15-
|`db:anonymize` | [ ] | |
16-
|`db:dump` | [ ] | |
17-
|`db:import` | [ ] | |
18-
|`db:list` | [ ] | |
19-
|`db:query` | [ ] | |
20-
|`log:exceptionlog` | [removed] | new new concept |
21-
|`misc:generate:documentation` | [ ] | |
22-
|`misc:generate:yaml:config` | [ ] | |
23-
|`misc:generate:yaml:module` | [ ] | |
24-
|`misc:phpstorm:metadata` | [ ] | |
25-
|`module:generate` | [ ] | |
10+
|`config:get` | [x] | |
11+
|`config:multiset` | [x] | |
12+
|`config:set` | [x] | |
13+
|`config:shop:get` | [x] | |
14+
|`config:shop:set` | [x] | |
15+
|`db:anonymize` | [x] | |
16+
|`db:dump` | [x] | |
17+
|`db:import` | [x] | |
18+
|`db:list` | [x] | |
19+
|`db:query` | [x] | |
20+
|`log:exceptionlog` | [removed] | need refactoring |
21+
|`misc:generate:documentation` | [x] | |
22+
|`misc:generate:yaml:config` | [x] | |
23+
|`misc:generate:yaml:module` | [removed] | oe:module:.. |
24+
|`misc:phpstorm:metadata` | [x] | |
25+
|`module:generate` | [x] | |
2626
|`module:activate` | [replaced] | oe:module:activate |
2727
|`module:deactivate` | [replaced] | oe:module:deactivate |
28-
|`module:list` | [ ] | |
29-
|`module:multiactivate` | [ ] | |
30-
|`module:reload` | [ ] | |
31-
|`oxid:shops` | [ ] | |
32-
|`route:debug` | [ ] | |
33-
|`user:create` | [ ] | |
34-
|`user:password` | [ ] | |
35-
|`views:update` | [ ] | |
28+
|`module:list` | [x] | |
29+
|`module:multiactivate` | [removed] | oe:module:.. |
30+
|`module:reload` | [x] | |
31+
|`oxid:shops` | [x] | |
32+
|`route:debug` | [x] | |
33+
|`user:create` | [x] | |
34+
|`user:password` | [x] | |
35+
|`views:update` | [x] | |

bin/generate_service_yaml.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,23 @@
77
* Time: 16:25
88
*/
99

10-
if (!file_exists(__DIR__ . '/../vendor/autoload.php')) {
11-
echo "Please run `composer install`";
12-
exit(2);
10+
$search_autoloader = [
11+
__DIR__ . "/../vendor/autoload.php",
12+
__DIR__ . "/../../../../vendor/autoload.php",
13+
];
14+
15+
$isAutoloaderFound = null;
16+
17+
foreach ($search_autoloader as $autoloader) {
18+
if (file_exists($autoloader)) {
19+
$isAutoloaderFound = include $autoloader;
20+
}
1321
}
1422

15-
require __DIR__ . '/../vendor/autoload.php';
23+
if ($isAutoloaderFound === null) {
24+
echo "Please run `composer install`" . PHP_EOL;
25+
exit(2);
26+
}
1627

1728
file_put_contents(
1829
__DIR__ . '/../services.yaml',

services.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,12 @@ services:
2525
tags: { name: console.command, command: 'misc:generate:documentation' }
2626
Oxrun\Command\Misc\GenerateYamlConfigCommand:
2727
tags: { name: console.command, command: 'misc:generate:yaml:config' }
28-
Oxrun\Command\Misc\GenerateYamlModuleListCommand:
29-
tags: { name: console.command, command: 'misc:generate:yaml:module' }
3028
Oxrun\Command\Misc\PhpstormMetadataCommand:
3129
tags: { name: console.command, command: 'misc:phpstorm:metadata' }
3230
Oxrun\Command\Module\GenerateCommand:
3331
tags: { name: console.command, command: 'module:generate' }
3432
Oxrun\Command\Module\ListCommand:
3533
tags: { name: console.command, command: 'module:list' }
36-
Oxrun\Command\Module\MultiActivateCommand:
37-
tags: { name: console.command, command: 'module:multiactivate' }
3834
Oxrun\Command\Module\ReloadCommand:
3935
tags: { name: console.command, command: 'module:reload' }
4036
Oxrun\Command\Oxid\ShopListCommand:

src/Oxrun/Command/Cache/ClearCommand.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Oxrun\Command\Cache;
44

55
use OxidEsales\Eshop\Core\Registry;
6-
use Oxrun\Traits\NoNeedDatabase;
76
use Symfony\Component\Console\Command\Command;
87
use Symfony\Component\Console\Input\InputInterface;
98
use Symfony\Component\Console\Input\InputOption;
@@ -14,10 +13,10 @@
1413
* Class ClearCommand
1514
* @package Oxrun\Command\Cache
1615
*/
17-
class ClearCommand extends Command implements \Oxrun\Command\EnableInterface
16+
class ClearCommand extends Command
1817
{
1918

20-
use NoNeedDatabase;
19+
// use NoNeedDatabase;
2120

2221
/**
2322
* Configures the current command.
@@ -53,6 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5352
$this->enterpriseCache($output);
5453

5554
$output->writeln('<info>Cache cleared.</info>');
55+
return 0;
5656
}
5757

5858
/**
@@ -62,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6262
*/
6363
protected function getCompileDir()
6464
{
65-
$oxidPath = $this->getApplication()->getShopDir();
65+
$oxidPath = OX_BASE_PATH;
6666
$configfile = $oxidPath . DIRECTORY_SEPARATOR . 'config.inc.php';
6767

6868
if ($oxidPath && file_exists($configfile)) {

src/Oxrun/Command/Config/GetCommand.php

+54-12
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@
33
namespace Oxrun\Command\Config;
44

55
use OxidEsales\Eshop\Core\Config;
6-
use Oxrun\Traits\NeedDatabase;
6+
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
7+
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
78
use Symfony\Component\Console\Command\Command;
89
use Symfony\Component\Console\Input\InputArgument;
910
use Symfony\Component\Console\Input\InputInterface;
1011
use Symfony\Component\Console\Input\InputOption;
1112
use Symfony\Component\Console\Output\OutputInterface;
13+
use Symfony\Component\Yaml\Yaml;
1214

1315
/**
1416
* Class GetCommand
1517
* @package Oxrun\Command\Config
1618
*/
17-
class GetCommand extends Command implements \Oxrun\Command\EnableInterface
19+
class GetCommand extends Command
1820
{
1921

20-
use NeedDatabase;
22+
// use NeedDatabase;
2123

2224
/**
2325
* Configures the current command.
@@ -28,7 +30,9 @@ protected function configure()
2830
->setName('config:get')
2931
->setDescription('Gets a config value')
3032
->addArgument('variableName', InputArgument::REQUIRED, 'Variable name')
31-
->addOption('moduleId', null, InputOption::VALUE_OPTIONAL, '');
33+
->addOption('moduleId', null, InputOption::VALUE_OPTIONAL, '')
34+
->addOption('json', null, InputOption::VALUE_NONE, 'Output as json')
35+
->addOption('yaml', null, InputOption::VALUE_NONE, 'Output as YAML (default)');
3236
}
3337

3438
/**
@@ -40,17 +44,55 @@ protected function configure()
4044
protected function execute(InputInterface $input, OutputInterface $output)
4145
{
4246
$oxConfig = oxNew(Config::class);
47+
48+
$varName = $input->getArgument('variableName');
49+
50+
$shopId = $input->getOption('shop-id');
51+
$moduleId = $input->getOption('moduleId');
52+
4353
$shopConfVar = $oxConfig->getShopConfVar(
44-
$input->getArgument('variableName'),
45-
$input->getOption('shopId'),
46-
$input->getOption('moduleId')
54+
$varName,
55+
$shopId,
56+
$moduleId
4757
);
48-
if (is_array($shopConfVar)) {
49-
$shopConfVar = json_encode($shopConfVar, true);
58+
59+
if ($shopConfVar === null) {
60+
$output->writeln("<error>$varName not found.</error>");
61+
return 2;
62+
}
63+
64+
if ($shopId) {
65+
$output_var[$varName]['shop-id'] = $shopId;
66+
}
67+
68+
if ($moduleId) {
69+
$output_var[$varName]['moduleId'] = $moduleId;
5070
}
51-
if( empty($shopConfVar)){
52-
$shopConfVar = 0;
71+
72+
$output_var[$varName]['type'] = $this->findType($varName);
73+
$output_var[$varName]['value'] = $shopConfVar;
74+
75+
if ($input->getOption('json')) {
76+
$output_var = \json_encode($output_var);
77+
} else {
78+
$output_var = Yaml::dump($output_var, 4, 2);
5379
}
54-
$output->writeln("<info>{$input->getArgument('variableName')} has value {$shopConfVar}</info>");
80+
81+
$output->writeln("<info>".$output_var."</info>");
82+
83+
return 0;
84+
}
85+
86+
public function findType($varName)
87+
{
88+
$qb = ContainerFactory::getInstance()->getContainer()->get(QueryBuilderFactoryInterface::class)->create();
89+
$qb->select('oxvartype' )
90+
->from('oxconfig')
91+
->where('OXVARNAME = :oxvarname')
92+
->setParameter('oxvarname', $varName)
93+
->setMaxResults(1);
94+
95+
$firstColumn = $qb->execute()->fetchFirstColumn();
96+
return array_shift($firstColumn);
5597
}
5698
}

src/Oxrun/Command/Config/MultiSetCommand.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Oxrun\Command\Config;
44

5-
use Oxrun\Traits\NeedDatabase;
5+
use Oxrun\Traits\OxrunConfigPool;
66
use Symfony\Component\Console\Command\Command;
77
use Symfony\Component\Console\Input\InputArgument;
88
use Symfony\Component\Console\Input\InputInterface;
@@ -34,9 +34,10 @@
3434
* @package Oxrun\Command\Config
3535
* @see example/malls.yml.dist
3636
*/
37-
class MultiSetCommand extends Command implements \Oxrun\Command\EnableInterface
37+
class MultiSetCommand extends Command
3838
{
39-
use NeedDatabase;
39+
use OxrunConfigPool;
40+
4041
/**
4142
* Configures the current command.
4243
*/
@@ -48,7 +49,7 @@ protected function configure()
4849
->addArgument('configfile', InputArgument::REQUIRED, 'The file containing the config values, see example/malls.yml.dist. (e.g. dev.yml, stage.yml, prod.yml)');
4950

5051
$help = <<<HELP
51-
The file path is relative to the shop installation_root_path/oxrun_config/.
52+
The file path is relative to the shop installation_root_path/oxrun_config/.
5253
You can also pass a YAML string on the command line.
5354
5455
To create YAML use command `oxrun misc:generate:yaml:multiset --help`
@@ -57,7 +58,7 @@ protected function configure()
5758
```yaml
5859
config:
5960
1:
60-
blReverseProxyActive:
61+
blReverseProxyActive:
6162
variableType: bool
6263
variableValue: false
6364
# simple string type
@@ -71,7 +72,7 @@ protected function configure()
7172
# optional module id
7273
moduleId: my_module
7374
2:
74-
blReverseProxyActive:
75+
blReverseProxyActive:
7576
...
7677
```
7778
[Example: malls.yml.dist](example/malls.yml.dist)
@@ -80,11 +81,11 @@ protected function configure()
8081
8182
```bash
8283
../vendor/bin/oxrun module:multiset $'config:\n 1:\n foobar: barfoo\n' --shopId=1
83-
```
84+
```
8485
HELP;
8586
$this->setHelp($help);
8687
}
87-
88+
8889
/**
8990
* Executes the current command.
9091
*
@@ -96,11 +97,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
9697
// do not use the registry pattern (\OxidEsales\Eshop\Core\Registry::getConfig()) here, so we do not have any caches (breaks unit tests)
9798
$oxConfig = oxNew(\OxidEsales\Eshop\Core\Config::class);
9899

99-
/* @var \Oxrun\Application $app */
100-
$app = $this->getApplication();
101-
102100
// now try to read YAML
103-
$mallYml = $app->getYaml($input->getArgument('configfile'));
101+
$mallYml = $this->getConfigYaml($input->getArgument('configfile'));
104102
$mallValues = Yaml::parse($mallYml);
105103

106104
if ($mallValues && is_array($mallValues['config'])) {
@@ -129,6 +127,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
129127
$output->writeln("<info>Config {$configKey} for shop {$shopId} set to " . print_r($variableValue, true) . "</info>");
130128
}
131129
}
130+
return 0;
132131
}
132+
return 1;
133133
}
134134
}

0 commit comments

Comments
 (0)