Passed
Pull Request — master (#6824)
by
unknown
08:35
created

Version20250926174000   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 28
rs 10
c 1
b 0
f 0
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 1
A up() 0 15 5
A down() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
8
9
use Chamilo\CoreBundle\DataFixtures\SettingsCurrentFixtures;
10
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
11
use Doctrine\DBAL\Schema\Schema;
12
13
class Version20250926174000 extends AbstractMigrationChamilo
14
{
15
    public function getDescription(): string
16
    {
17
        return 'Update settings.category using categories from SettingsCurrentFixtures';
18
    }
19
20
    public function up(Schema $schema): void
21
    {
22
        foreach (SettingsCurrentFixtures::getExistingSettings() as $category => $settings) {
23
            $category = strtolower((string) $category);
24
            foreach ($settings as $setting) {
25
                $variable = $setting['name'];
26
                $this->addSql("UPDATE settings SET category = '{$category}' WHERE variable = '{$variable}'");
27
            }
28
        }
29
30
        foreach (SettingsCurrentFixtures::getNewConfigurationSettings() as $category => $settings) {
31
            $category = strtolower((string) $category);
32
            foreach ($settings as $setting) {
33
                $variable = $setting['name'];
34
                $this->addSql("UPDATE settings SET category = '{$category}' WHERE variable = '{$variable}'");
35
            }
36
        }
37
    }
38
39
    public function down(Schema $schema): void
40
    {
41
        // no-op
42
    }
43
}
44