Passed
Push — master ( ccaaed...17ba08 )
by Josh
02:25
created

Update_001_000_000_beta::assignDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Auto Generated from Blender
5
 * Date: 2017/11/10 at 15:29:37 EST -05:00
6
 */
7
8
use \LCI\Blend\Migrations;
9
10
class Update_001_000_000_beta extends Migrations
11
{
12
13
    protected $empty_settings = [
14
        'blend.portable.systemSettings.templates',
15
        'blend.portable.systemSettings.mediaSources',
16
        'blend.portable.systemSettings.resources',
17
18
        'blend.portable.templateVariables.templates',
19
        'blend.portable.templateVariables.mediaSources',
20
        'blend.portable.templateVariables.resources',
21
    ];
22
23
    /**
24
     * Run the migrations.
25
     *
26
     * @return void
27
     */
28
    public function up()
29
    {
30
        // only thing to change is the version number
31
32
        /** @var \LCI\Blend\Blendable\SystemSetting $systemSetting */
33
        $systemSetting = $this->blender->getBlendableLoader()->getBlendableSystemSetting('blend.version');
34
        $systemSetting
35
            ->setSeedsDir($this->getSeedsDir())
36
            ->setFieldValue('1.0.0 beta')
37
            ->setFieldArea('Blend')
38
            ->blend(true);
39
40
        foreach ($this->empty_settings as $key) {
41
42
            /** @var \LCI\Blend\Blendable\SystemSetting $systemSetting */
43
            $systemSetting = $this->blender->getBlendableLoader()->getBlendableSystemSetting($key);
44
            $systemSetting
45
                ->setSeedsDir($this->getSeedsDir())
46
                ->setFieldArea('Blend')
47
                ->blend(true);
48
        }
49
50
        $this->modx->cacheManager->refresh();
51
    }
52
53
    /**
54
     * Reverse the migrations.
55
     *
56
     * @return void
57
     */
58
    public function down()
59
    {
60
        /** @var \LCI\Blend\Blendable\SystemSetting $systemSetting */
61
        $systemSetting = $this->blender->getBlendableLoader()->getBlendableSystemSetting('blend.version');
62
        $systemSetting
63
            ->setSeedsDir($this->getSeedsDir())
64
            ->revertBlend();
65
66
        foreach ($this->empty_settings as $key) {
67
68
            /** @var \LCI\Blend\Blendable\SystemSetting $systemSetting */
69
            $systemSetting = $this->blender->getBlendableLoader()->getBlendableSystemSetting($key);
70
            $systemSetting
71
                ->setSeedsDir($this->getSeedsDir())
72
                ->revertBlend();
73
        }
74
75
        $this->modx->cacheManager->refresh();
76
    }
77
78
    /**
79
     * Method is called on construct, please fill me in
80
     */
81
    protected function assignDescription()
82
    {
83
        $this->description = 'Update Blend to v1.0.0 beta from v0.9.11 and below';
84
    }
85
86
    /**
87
     * Method is called on construct, please fill me in
88
     */
89
    protected function assignVersion()
90
    {
91
        $this->version = '1.0.0 beta';
92
    }
93
94
    /**
95
     * Method is called on construct, can change to only run this migration for those types
96
     */
97
    protected function assignType()
98
    {
99
        $this->type = 'master';
100
    }
101
102
    /**
103
     * Method is called on construct, Child class can override and implement this
104
     */
105
    protected function assignSeedsDir()
106
    {
107
        $this->seeds_dir = 'Update_001_000_000_beta';
108
    }
109
}
110