Passed
Push — master ( f762ef...190e8a )
by Julito
09:11
created

Version20160421112900   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 40 3
A down() 0 2 1
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Migrations\Schema\V111;
5
6
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
7
use Doctrine\DBAL\Schema\Schema;
8
use Doctrine\DBAL\Types\Type;
9
10
/**
11
 * Class Version_a
12
 * Remove enable_nanogong and enable_wami_record settings and create enable_record_audio
13
 * @package Chamilo\CoreBundle\Migrations\Schema\V111
14
 */
15
class Version20160421112900 extends AbstractMigrationChamilo
16
{
17
    /**
18
     * @param Schema $schema
19
     * @throws \Doctrine\DBAL\Schema\SchemaException
20
     */
21
    public function up(Schema $schema)
22
    {
23
        $em = $this->getEntityManager();
24
25
        $enableNanogong = $em
26
            ->getRepository('ChamiloCoreBundle:SettingsCurrent')
27
            ->findOneBy(['variable' => 'enable_nanogong']);
28
29
        $enableWami = $em
30
            ->getRepository('ChamiloCoreBundle:SettingsCurrent')
31
            ->findOneBy(['variable' => 'enable_wami_record']);
32
33
        $enableRecordAudioValue = 'true';
34
35
        if ($enableNanogong->getSelectedValue() === 'false' && $enableWami->getSelectedValue() === 'false') {
36
            $enableRecordAudioValue = 'false';
37
        }
38
39
        $this->addSettingCurrent(
40
            'enable_record_audio',
41
            null,
42
            'radio',
43
            'Course',
44
            $enableRecordAudioValue,
45
            'EnableRecordAudioTitle',
46
            'EnableRecordAudioComment',
47
            null,
48
            '',
49
            1,
50
            true,
51
            false,
52
            [
53
                ['value' => 'false', 'text' => 'No'],
54
                ['value' => 'true', 'text' => 'Yes']
55
            ]
56
        );
57
58
        $em->remove($enableNanogong);
59
        $em->remove($enableWami);
60
        $em->flush();
61
    }
62
63
    /**
64
     * @param Schema $schema
65
     */
66
    public function down(Schema $schema)
67
    {
68
69
    }
70
}
71