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

Version20160705192000::up()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 1
dl 0
loc 13
rs 10
c 0
b 0
f 0
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 Version20160705192000
12
 * Add accumulate scorm time to c_lp table
13
 * @package Chamilo\CoreBundle\Migrations\Schema\V111
14
 */
15
class Version20160705192000 extends AbstractMigrationChamilo
16
{
17
    /**
18
     * @param Schema $schema
19
     * @throws \Doctrine\DBAL\DBALException
20
     * @throws \Doctrine\DBAL\Schema\SchemaException
21
     */
22
    public function up(Schema $schema)
23
    {
24
        $em = $this->getEntityManager();
25
26
        $result = $em
27
            ->getRepository('ChamiloCoreBundle:SettingsCurrent')
28
            ->findOneBy(['variable' => 'scorm_cumulative_session_time']);
29
30
        $cumulativeScormTime = 1;
31
        if ($result->getSelectedValue() === 'false') {
32
            $cumulativeScormTime = 0;
33
        }
34
        $this->addSql("UPDATE c_lp SET accumulate_scorm_time = $cumulativeScormTime");
35
    }
36
37
    /**
38
     * @param Schema $schema
39
     * @throws \Doctrine\DBAL\DBALException
40
     * @throws \Doctrine\DBAL\Schema\SchemaException
41
     */
42
    public function down(Schema $schema)
43
    {
44
45
    }
46
}
47