Completed
Push — ezp25946-migrate_files_to_othe... ( 3ba3f5...7b23be )
by
unknown
13:29
created

MigrationHandlerPass::process()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nc 4
nop 1
dl 0
loc 18
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the MigrationHandlerPass class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Bundle\EzPublishIOBundle\DependencyInjection\Compiler;
10
11
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
12
use Symfony\Component\DependencyInjection\ContainerBuilder;
13
use Symfony\Component\DependencyInjection\Reference;
14
15
class MigrationHandlerPass implements CompilerPassInterface
16
{
17
    /**
18
     * Registers the MigrationHandlerInterface into the migration handler registry.
19
     *
20
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
21
     */
22
    public function process(ContainerBuilder $container)
23
    {
24
        if (!$container->has('ezpublish.core.io.migration.migration_handler_registry')) {
25
            return;
26
        }
27
28
        $migrationHandlersTagged = $container->findTaggedServiceIds('ezpublish.core.io.migration.migration_handler');
29
30
        $migrationHandlers = [];
31
        foreach ($migrationHandlersTagged as $id => $tags) {
32
            foreach ($tags as $attributes) {
33
                $migrationHandlers[$attributes['identifier']] = new Reference($id);
34
            }
35
        }
36
37
        $migrationHandlerRegistryDef = $container->findDefinition('ezpublish.core.io.migration.migration_handler_registry');
38
        $migrationHandlerRegistryDef->setArguments([$migrationHandlers]);
39
    }
40
}
41