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

MigrationHandlerPass   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 4
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