Key::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
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) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

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.

Loading history...
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