SiteConfigMigration::onAfterWrite()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 16
ccs 0
cts 12
cp 0
rs 9.9
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Dynamic\FoxyStripe\ORM;
4
5
use Dynamic\FoxyStripe\Model\FoxyStripeSetting;
6
use SilverStripe\Forms\CheckboxField;
7
use SilverStripe\Forms\FieldList;
8
use SilverStripe\Forms\HeaderField;
9
use SilverStripe\Forms\LiteralField;
10
use SilverStripe\Forms\ReadonlyField;
11
use SilverStripe\Forms\TextField;
12
use SilverStripe\ORM\DataExtension;
13
14
/**
15
 * Class SiteConfigMigration
16
 *
17
 * Apply this DataExtension to SiteConfig and hit Save. Data will be migrated to FoxyStripeSetting
18
 * via the onAfterWrite() function.
19
 *
20
 * @package Dynamic\FoxyStripe\ORM
21
 */
22
class SiteConfigMigration extends DataExtension
23
{
24
    /**
25
     * @var array
26
     */
27
    private static $db = array(
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
28
        'StoreName' => 'Varchar(255)',
29
        'StoreKey' => 'Varchar(60)',
30
        'MultiGroup' => 'Boolean',
31
        'ProductLimit' => 'Int',
32
        'CartValidation' => 'Boolean',
33
        'MaxQuantity' => 'Int',
34
        'CustomSSL' => 'Boolean',
35
        'RemoteDomain' => 'Varchar(255)',
36
    );
37
38
    /**
39
     *
40
     */
41
    public function onAfterWrite()
42
    {
43
        parent::onAfterWrite();
44
45
        $config = FoxyStripeSetting::current_foxystripe_setting();
46
47
        $config->StoreName = $this->owner->StoreName;
48
        $config->StoreKey = $this->owner->StoreKey;
49
        $config->MultiGroup = $this->owner->MultiGroup;
50
        $config->ProductLimit = $this->owner->ProductLimit;
51
        $config->CartValidation = $this->owner->CartValidation;
52
        $config->MaxQuantity = $this->owner->MaxQuantity;
53
        $config->CustomSSL = $this->owner->CustomSSL;
0 ignored issues
show
Bug Best Practice introduced by
The property CustomSSL does not exist on Dynamic\FoxyStripe\Model\FoxyStripeSetting. Since you implemented __set, consider adding a @property annotation.
Loading history...
54
        $config->RemoteDomain = $this->owner->RemoteDomain;
0 ignored issues
show
Bug Best Practice introduced by
The property RemoteDomain does not exist on Dynamic\FoxyStripe\Model\FoxyStripeSetting. Since you implemented __set, consider adding a @property annotation.
Loading history...
55
56
        $config->write();
57
    }
58
}
59