Passed
Pull Request — master (#16)
by
unknown
03:49
created

UpgradeData::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace DigitalOrigin\Pmt\Setup;
4
5
use Magento\Framework\Setup\UpgradeDataInterface;
6
use Magento\Framework\Setup\ModuleContextInterface;
7
use Magento\Framework\Setup\ModuleDataSetupInterface;
8
use DigitalOrigin\Pmt\Helper\Config;
9
10
class UpgradeData implements UpgradeDataInterface
11
{
12
    /** Config tablename */
13
    const CONFIG_TABLE = 'pmt_config';
14
15
    /** @var Config */
16
    public $config;
17
18
    public function __construct(Config $config)
19
    {
20
        $this->config = $config;
21
    }
22
23
    /**
24
     * @param ModuleDataSetupInterface $setup
25
     * @param ModuleContextInterface   $context
26
     */
27
    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
28
    {
29
        $setup->startSetup();
30
31
        if (version_compare($context->getVersion(), '7.2.0') < 0) {
32
            $newConfigs = array(
33
                /* INSERT NEW CONFIGS PARAMS HERE:'config'=>'<config>','value'=>'<value>'*/);
34
            foreach ($newConfigs as $config => $value) {
35
                $setup->getConnection()->insert(self::CONFIG_TABLE, array('config'=>$config, 'value'=>$value));
36
            }
37
        }
38
39
        $setup->endSetup();
40
    }
41
}