Passed
Push — trunk ( fb06e2...91b192 )
by Christian
11:15 queued 12s
created

ElasticsearchMigrationCompilerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 0
loc 12
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Elasticsearch\DependencyInjection;
4
5
use Shopware\Core\Framework\Log\Package;
6
use Shopware\Core\Framework\Migration\MigrationSource;
7
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
10
#[Package('core')]
11
class ElasticsearchMigrationCompilerPass implements CompilerPassInterface
12
{
13
    public function process(ContainerBuilder $container): void
14
    {
15
        $migrationPath = \dirname(__DIR__) . '/Migration';
16
17
        // configure migration directories
18
        $majors = ['V6_5', 'V6_6'];
19
        foreach ($majors as $major) {
20
            $migrationPathV5 = $migrationPath . '/' . $major;
21
22
            if (\is_dir($migrationPathV5)) {
23
                $migrationSource = $container->getDefinition(MigrationSource::class . '.core.' . $major);
24
                $migrationSource->addMethodCall('addDirectory', [$migrationPathV5, 'Shopware\Elasticsearch\Migration\\' . $major]);
25
            }
26
        }
27
    }
28
}
29