1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of EC-CUBE |
4
|
|
|
* |
5
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
6
|
|
|
* |
7
|
|
|
* http://www.lockon.co.jp/ |
8
|
|
|
* |
9
|
|
|
* This program is free software; you can redistribute it and/or |
10
|
|
|
* modify it under the terms of the GNU General Public License |
11
|
|
|
* as published by the Free Software Foundation; either version 2 |
12
|
|
|
* of the License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU General Public License |
20
|
|
|
* along with this program; if not, write to the Free Software |
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
namespace Eccube\Command; |
25
|
|
|
|
26
|
|
|
use Knp\Command\Command; |
27
|
|
|
use Symfony\Component\Console\Application; |
28
|
|
|
use Symfony\Component\Console\Formatter\OutputFormatterStyle; |
29
|
|
|
use Symfony\Component\Console\Helper\TableHelper; |
30
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
31
|
|
|
use Symfony\Component\Console\Input\InputDefinition; |
32
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
33
|
|
|
use Symfony\Component\Console\Input\InputOption; |
34
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
class ConfigCommand extends Command |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
protected function configure() |
40
|
|
|
{ |
41
|
|
|
$this |
42
|
|
|
->setName('debug:config') |
43
|
|
|
->setDefinition(array( |
44
|
|
|
new InputArgument('filter', InputArgument::OPTIONAL, 'Show details for all config matching this filter'), |
45
|
|
|
new InputOption('configphp', null, InputOption::VALUE_NONE, 'Check if you are using Config PHP File'), |
46
|
|
|
)) |
47
|
|
|
->setDescription('Shows a list of config file') |
48
|
|
|
->setHelp(<<<EOF |
49
|
|
|
The <info>%command.name%</info> command outputs a list of config file, |
50
|
|
|
Output can be filtered with an optional argument. |
51
|
|
|
|
52
|
|
|
<info>php %command.full_name%</info> |
53
|
|
|
|
54
|
|
|
The command lists all config. |
55
|
|
|
|
56
|
|
|
<info>php %command.full_name% database</info> |
57
|
|
|
|
58
|
|
|
The command lists the database yml file. |
59
|
|
|
For filter, yml file name or key name can be set. |
60
|
|
|
|
61
|
|
|
<info>php %command.full_name% --configphp</info> |
62
|
|
|
|
63
|
|
|
The command checks whether Config PHP File is used. |
64
|
|
|
|
65
|
|
|
EOF |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
71
|
|
|
{ |
72
|
|
|
|
73
|
|
|
/** @var \Eccube\Application $app */ |
74
|
|
|
$app = $this->getSilexApplication(); |
75
|
|
|
|
76
|
|
|
$filter = $input->getArgument('filter'); |
77
|
|
|
|
78
|
|
|
$optional = $input->getOption('configphp'); |
79
|
|
|
if ($optional) { |
80
|
|
|
// ymlファイルではなく、phpファイルが有効になっているかチェック |
81
|
|
|
$ymlPath = $this->getProjectDirectory().'/app/config/eccube'; |
82
|
|
|
$config_php = $ymlPath.'/config.php'; |
83
|
|
|
if (file_exists($config_php)) { |
84
|
|
|
$output->writeln('Config PHP File : <info>used.</info>'); |
85
|
|
|
} else { |
86
|
|
|
$output->writeln('Config PHP File : <info>not used.</info>'); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
if (!$filter) { |
90
|
|
|
return; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
$recursive = function ($config, $space = ' ') use (&$recursive, $output) { |
95
|
|
|
foreach ($config as $key => $item) { |
96
|
|
|
if (is_array($item)) { |
97
|
|
|
$space = ' '; |
98
|
|
|
$output->writeln($space."<comment>{$key}</comment> :"); |
99
|
|
|
$space .= ' '; |
100
|
|
|
|
101
|
|
|
$recursive($item, $space); |
102
|
|
|
} else { |
103
|
|
|
$output->writeln($space."<comment>{$key}</comment> : <info>{$item}</info>"); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
}; |
107
|
|
|
|
108
|
|
|
|
109
|
|
|
if ($filter) { |
110
|
|
|
// コマンド実行時にパラメータを指定 |
111
|
|
|
|
112
|
|
|
$config = array(); |
113
|
|
|
$app->parseConfig($filter, $config); |
114
|
|
|
|
115
|
|
View Code Duplication |
if (!empty($config)) { |
116
|
|
|
// ymlファイル名が指定された場合、ymlファイルの内容を出力 |
117
|
|
|
$output->writeln("YML File Name : <info>{$filter}</info>"); |
118
|
|
|
foreach ($config as $key => $item) { |
119
|
|
|
if (is_array($item)) { |
120
|
|
|
$output->writeln("<comment>{$key}</comment> :"); |
121
|
|
|
$recursive($item); |
122
|
|
|
} else { |
123
|
|
|
$output->writeln("<comment>{$key}</comment> : <info>{$item}</info>"); |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
return; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
if (!isset($app['config'][$filter])) { |
131
|
|
|
$output->writeln('Not Found filter : $app[\'config\'][\'<error>'.$filter.'</error>\']'); |
132
|
|
|
|
133
|
|
|
return; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
$config = $app['config'][$filter]; |
137
|
|
|
|
138
|
|
|
$output->writeln('$app[\'config\'][\'<comment>'.$filter.'</comment>\']'); |
139
|
|
View Code Duplication |
if (is_array($config)) { |
140
|
|
|
foreach ($config as $key => $item) { |
141
|
|
|
if (is_array($item)) { |
142
|
|
|
$output->writeln("<comment>{$key}</comment> :"); |
143
|
|
|
$recursive($item); |
144
|
|
|
} else { |
145
|
|
|
$output->writeln("<comment>{$key}</comment> : <info>{$item}</info>"); |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
} else { |
149
|
|
|
$output->writeln("<comment>{$filter}</comment> : <info>{$config}</info>"); |
150
|
|
|
} |
151
|
|
View Code Duplication |
} else { |
152
|
|
|
// $app['config']の内容を全て出力する |
|
|
|
|
153
|
|
|
$config = $app['config']; |
154
|
|
|
|
155
|
|
|
foreach ($config as $key => $item) { |
156
|
|
|
if (is_array($item)) { |
157
|
|
|
$output->writeln("<comment>{$key}</comment> :"); |
158
|
|
|
$recursive($item); |
159
|
|
|
} else { |
160
|
|
|
$output->writeln("<comment>{$key}</comment> : <info>{$item}</info>"); |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
} |
166
|
|
|
|