1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* netz98 magento module |
4
|
|
|
* |
5
|
|
|
* LICENSE |
6
|
|
|
* |
7
|
|
|
* This source file is subject of netz98. |
8
|
|
|
* You may be not allowed to change the sources |
9
|
|
|
* without authorization of netz98 new media GmbH. |
10
|
|
|
* |
11
|
|
|
* @copyright Copyright (c) 1999-2016 netz98 new media GmbH (http://www.netz98.de) |
12
|
|
|
* @author netz98 new media GmbH <[email protected]> |
13
|
|
|
* @category N98 |
14
|
|
|
* @package N98\Magento\Command\Developer\Console |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace N98\Magento\Command\Developer\Console\Config; |
18
|
|
|
|
19
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
20
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
21
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
22
|
|
|
|
23
|
|
View Code Duplication |
class MakeConfigSystemCommand extends AbstractSimpleConfigFileGeneratorCommand |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
const CONFIG_FILENAME = 'system.xml'; |
26
|
|
|
|
27
|
|
|
protected function configure() |
28
|
|
|
{ |
29
|
|
|
$this |
30
|
|
|
->setName('make:config:system') |
31
|
|
|
->addArgument('area', InputArgument::OPTIONAL, 'Area of system.xml file', 'adminhtml') |
32
|
|
|
->setDescription('Creates a new system.xml file') |
33
|
|
|
; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param InputInterface $input |
38
|
|
|
* @param OutputInterface $output |
39
|
|
|
* |
40
|
|
|
* @return int|void |
41
|
|
|
*/ |
42
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
43
|
|
|
{ |
44
|
|
|
$selectedArea = $input->getArgument('area'); |
45
|
|
|
$relativeConfigFilePath = $this->getRelativeConfigFilePath(self::CONFIG_FILENAME, $selectedArea); |
46
|
|
|
|
47
|
|
|
if ($this->getCurrentModuleDirectoryReader()->isExist($relativeConfigFilePath)) { |
48
|
|
|
$output->writeln('<warning>File already exists. Skiped generation</warning>'); |
49
|
|
|
|
50
|
|
|
return; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$referenceConfigFileContent = file_get_contents(__DIR__ . '/_files/reference_system.xml'); |
54
|
|
|
$this->getCurrentModuleDirectoryWriter()->writeFile($relativeConfigFilePath, $referenceConfigFileContent); |
55
|
|
|
|
56
|
|
|
$output->writeln('<info>generated </info><comment>' . $relativeConfigFilePath . '</comment>'); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.