Passed
Push — master ( db4ea6...d5460f )
by Julito
11:23
created

Version20211029123419   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
c 1
b 0
f 1
dl 0
loc 23
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A down() 0 2 1
A up() 0 11 2
A getDescription() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
6
7
use Chamilo\CoreBundle\Component\Utils\CreateDefaultPages;
8
use Chamilo\CoreBundle\Entity\AccessUrl;
9
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
10
use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository;
11
use Doctrine\DBAL\Schema\Schema;
12
13
final class Version20211029123419 extends AbstractMigrationChamilo
14
{
15
    public function getDescription(): string
16
    {
17
        return 'Page entity';
18
    }
19
20
    public function up(Schema $schema): void
21
    {
22
        if ($schema->hasTable('page')) {
23
            $container = $this->getContainer();
24
            $createDefaultPages = $container->get(CreateDefaultPages::class);
25
26
            $urlRepo = $container->get(AccessUrlRepository::class);
27
            $urlList = $urlRepo->findAll();
28
            /** @var AccessUrl $url */
29
            $url = $urlList[0];
30
            $createDefaultPages->createDefaultPages($this->getAdmin(), $url, 'en_US');
31
        }
32
    }
33
34
    public function down(Schema $schema): void
35
    {
36
    }
37
}
38