1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LimeSoda\Ess\M2ePro\License; |
4
|
|
|
|
5
|
|
|
use N98\Magento\Command\AbstractMagentoCommand; |
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
9
|
|
|
|
10
|
|
|
class Key extends AbstractMagentoCommand |
11
|
|
|
{ |
12
|
|
|
const EXTENSION_NAME = 'Ess_M2ePro'; |
13
|
|
|
|
14
|
|
|
protected function configure() |
15
|
|
|
{ |
16
|
|
|
$this |
17
|
|
|
->setName('ls:ess:m2epro:license:key') |
18
|
|
|
->addArgument('key', InputArgument::REQUIRED, 'Ess_M2ePro license key') |
19
|
|
|
->setDescription('Set the Ess_M2ePro license key') |
20
|
|
|
->setHelp( |
21
|
|
|
<<<EOT |
22
|
|
|
Sets the license key for Ess_M2ePro. The extension has to be installed and enabled. |
23
|
|
|
EOT |
24
|
|
|
); |
25
|
|
|
|
26
|
|
|
; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
31
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
32
|
|
|
* @return int|void |
33
|
|
|
*/ |
34
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
35
|
|
|
{ |
36
|
|
|
$this->detectMagento($output); |
37
|
|
|
if ($this->initMagento()) { |
38
|
|
View Code Duplication |
if (\Mage::helper('core')->isModuleEnabled(self::EXTENSION_NAME) === false) { |
|
|
|
|
39
|
|
|
throw new \Exception("Extension '" . self::EXTENSION_NAME ."' is not installed."); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$key = strip_tags($input->getArgument('key')); |
43
|
|
|
|
44
|
|
|
\Mage::helper('M2ePro/Primary')->getConfig()->setGroupValue( |
45
|
|
|
'/'.\Mage::helper('M2ePro/Module')->getName().'/license/', 'key',(string)$key |
46
|
|
|
); |
47
|
|
|
|
48
|
|
|
\Mage::getModel('M2ePro/Servicing_Dispatcher')->processTasks( |
49
|
|
|
array(\Mage::getModel('M2ePro/Servicing_Task_License')->getPublicNick()) |
50
|
|
|
); |
51
|
|
|
|
52
|
|
|
\Mage::helper('M2ePro/data_cache')->removeValue('M2ePro/Config_Primary_data'); |
53
|
|
|
|
54
|
|
|
$output->writeln("Set license key '" . $key . "'."); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
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.