netz98 /
n98-magerun2
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace N98\Magento\Command\Config; |
||
| 4 | |||
| 5 | use Symfony\Component\Console\Input\InputArgument; |
||
| 6 | use Symfony\Component\Console\Input\InputInterface; |
||
| 7 | use Symfony\Component\Console\Input\InputOption; |
||
| 8 | use Symfony\Component\Console\Output\OutputInterface; |
||
| 9 | |||
| 10 | class SetCommand extends AbstractConfigCommand |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var array |
||
| 14 | */ |
||
| 15 | protected $_scopes = array( |
||
| 16 | 'default', |
||
| 17 | 'websites', |
||
| 18 | 'stores', |
||
| 19 | ); |
||
| 20 | |||
| 21 | View Code Duplication | protected function configure() |
|
| 22 | { |
||
| 23 | $this |
||
| 24 | ->setName('config:set') |
||
| 25 | ->setDescription('Set a core config item') |
||
| 26 | ->addArgument('path', InputArgument::REQUIRED, 'The config path') |
||
| 27 | ->addArgument('value', InputArgument::REQUIRED, 'The config value') |
||
| 28 | ->addOption('scope', null, InputOption::VALUE_OPTIONAL, 'The config value\'s scope (default, websites, stores)', 'default') |
||
|
0 ignored issues
–
show
|
|||
| 29 | ->addOption('scope-id', null, InputOption::VALUE_OPTIONAL, 'The config value\'s scope ID', '0') |
||
| 30 | ->addOption('encrypt', null, InputOption::VALUE_NONE, 'The config value should be encrypted using local.xml\'s crypt key') |
||
|
0 ignored issues
–
show
|
|||
| 31 | ; |
||
| 32 | |||
| 33 | $help = <<<HELP |
||
| 34 | Set a store config value by path. |
||
| 35 | To set a value of a specify store view you must set the "scope" and "scope-id" option. |
||
| 36 | |||
| 37 | HELP; |
||
| 38 | $this->setHelp($help); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param \Symfony\Component\Console\Input\InputInterface $input |
||
| 43 | * @param \Symfony\Component\Console\Output\OutputInterface $output |
||
| 44 | * @return int|void |
||
| 45 | */ |
||
| 46 | protected function execute(InputInterface $input, OutputInterface $output) |
||
| 47 | { |
||
| 48 | $this->detectMagento($output, true); |
||
| 49 | if ($this->initMagento()) { |
||
| 50 | $this->_validateScopeParam($input->getOption('scope')); |
||
| 51 | $scopeId = $this->_convertScopeIdParam($input->getOption('scope'), $input->getOption('scope-id')); |
||
| 52 | |||
| 53 | $value = str_replace(array('\n', '\r'), array("\n", "\r"), $input->getArgument('value')); |
||
| 54 | $value = $this->_formatValue($value, ($input->getOption('encrypt') ? 'encrypt' : false)); |
||
| 55 | |||
| 56 | |||
| 57 | $this->getConfigWriter()->save( |
||
| 58 | $input->getArgument('path'), |
||
| 59 | $value, |
||
| 60 | $input->getOption('scope'), |
||
| 61 | $scopeId |
||
| 62 | ); |
||
| 63 | |||
| 64 | $output->writeln('<comment>' . $input->getArgument('path') . "</comment> => <comment>" . $input->getArgument('value') . '</comment>'); |
||
|
0 ignored issues
–
show
|
|||
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.