Completed
Push — 1.10.x ( 2635b5...f0080b )
by Yannick
165:55 queued 120:08
created

Version20150821150000::up()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 82
Code Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 46
nc 1
nop 1
dl 0
loc 82
rs 8.7769
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Application\Migrations\Schema\V110;
5
6
use Application\Migrations\AbstractMigrationChamilo;
7
use Doctrine\DBAL\Schema\Schema;
8
9
/**
10
 * Class Version20150821150000
11
 *
12
 * @package Application\Migrations\Schema\V11010
13
 */
14
class Version20150821150000 extends AbstractMigrationChamilo
15
{
16
17
    /**
18
     * @param Schema $schema
19
     */
20
    public function up(Schema $schema)
21
    {
22
        $entityManage = $this->getEntityManager();
23
24
        $deleteOptions = $entityManage->createQueryBuilder();
25
        $deleteSettings = $entityManage->createQueryBuilder();
26
27
        $deleteOptions->delete('ChamiloCoreBundle:SettingsOptions', 'o')
28
            ->andWhere(
29
                $deleteOptions->expr()->in(
30
                    'o.variable',
31
                    [
32
                        'display_mini_month_calendar'
33
                    ]
34
                )
35
            );
36
        $deleteOptions->getQuery()->execute();
37
38
        $deleteSettings->delete('ChamiloCoreBundle:SettingsCurrent', 's')
39
            ->andWhere(
40
                $deleteSettings->expr()->in(
41
                    's.variable',
42
                    [
43
                        'display_mini_month_calendar'
44
                    ]
45
                )
46
            );
47
        $deleteSettings->getQuery()->execute();
48
        $deleteOptions->delete('ChamiloCoreBundle:SettingsOptions', 'o')
49
            ->andWhere(
50
                $deleteOptions->expr()->in(
51
                    'o.variable',
52
                    [
53
                        'display_upcoming_events'
54
                    ]
55
                )
56
            );
57
        $deleteOptions->getQuery()->execute();
58
59
        $deleteSettings->delete('ChamiloCoreBundle:SettingsCurrent', 's')
60
            ->andWhere(
61
                $deleteSettings->expr()->in(
62
                    's.variable',
63
                    [
64
                        'display_upcoming_events'
65
                    ]
66
                )
67
            );
68
        $deleteSettings->getQuery()->execute();
69
        $deleteSettings->delete('ChamiloCoreBundle:SettingsCurrent', 's')
70
            ->andWhere(
71
                $deleteSettings->expr()->in(
72
                    's.variable',
73
                    [
74
                        'number_of_upcoming_events'
75
                    ]
76
                )
77
            );
78
        $deleteSettings->getQuery()->execute();
79
80
        $deleteOptions->delete('ChamiloCoreBundle:SettingsOptions', 'o')
81
            ->andWhere(
82
                $deleteOptions->expr()->in(
83
                    'o.variable',
84
                    [
85
                        'allow_reservation'
86
                    ]
87
                )
88
            );
89
        $deleteOptions->getQuery()->execute();
90
91
        $deleteSettings->delete('ChamiloCoreBundle:SettingsCurrent', 's')
92
            ->andWhere(
93
                $deleteSettings->expr()->in(
94
                    's.variable',
95
                    [
96
                        'allow_reservation'
97
                    ]
98
                )
99
            );
100
        $deleteSettings->getQuery()->execute();
101
    }
102
103
    /**
104
     * @param Schema $schema
105
     */
106
    public function down(Schema $schema)
107
    {
108
        $this->addSettingCurrent(
109
            'display_mini_month_calendar',
110
            null,
111
            'radio',
112
            'Tools',
113
            'true',
114
            'DisplayMiniMonthCalendarTitle',
115
            'DisplayMiniMonthCalendarComment',
116
            null,
117
            null,
118
            1,
119
            false,
120
            false,
121
            [
122
                0 => ['value' => 'true', 'text' => 'Yes'],
123
                1 => ['value' => 'false', 'text' => 'No']
124
            ]
125
        );
126
        $this->addSettingCurrent(
127
            'display_upcoming_events',
128
            null,
129
            'radio',
130
            'Tools',
131
            'true',
132
            'DisplayUpcomingEventsTitle',
133
            'DisplayUpcomingEventsComment',
134
            null,
135
            null,
136
            1,
137
            false,
138
            false,
139
            [
140
                0 => ['value' => 'true', 'text' => 'Yes'],
141
                1 => ['value' => 'false', 'text' => 'No']
142
            ]
143
        );
144
        $this->addSettingCurrent(
145
            'number_of_upcoming_events',
146
            null,
147
            'textfield',
148
            'Tools',
149
            '1',
150
            'NumberOfUpcomingEventsTitle',
151
            'NumberOfUpcomingEventsComment',
152
            null,
153
            null,
154
            1,
155
            false,
156
            false
157
        );
158
        $this->addSettingCurrent(
159
            'allow_reservation',
160
            null,
161
            'radio',
162
            'Tools',
163
            'false',
164
            'AllowReservationTitle',
165
            'AllowReservationComment',
166
            null,
167
            null,
168
            1,
169
            true,
170
            false,
171
            [
172
                0 => ['value' => 'true', 'text' => 'Yes'],
173
                1 => ['value' => 'false', 'text' => 'No']
174
            ]
175
        );
176
    }
177
178
}
179