DataTablesProviderCompilerPass   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 16
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 11 3
1
<?php
2
3
/*
4
 * This file is part of the jquery-datatables-bundle package.
5
 *
6
 * (c) 2018 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\JQuery\DataTablesBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Reference;
17
use WBW\Bundle\JQuery\DataTablesBundle\Manager\DataTablesManager;
18
use WBW\Bundle\JQuery\DataTablesBundle\Provider\DataTablesProviderInterface;
19
20
/**
21
 * jQuery DataTables provider compiler pass.
22
 *
23
 * @author webeweb <https://github.com/webeweb>
24
 * @package WBW\Bundle\JQuery\DataTablesBundle\DependencyInjection\Compiler
25
 */
26
class DataTablesProviderCompilerPass implements CompilerPassInterface {
27
28
    /**
29
     * {@inheritDoc}
30
     */
31
    public function process(ContainerBuilder $container): void {
32
33
        if (false === $container->has(DataTablesManager::SERVICE_NAME)) {
34
            return;
35
        }
36
37
        $manager = $container->findDefinition(DataTablesManager::SERVICE_NAME);
38
39
        $providers = $container->findTaggedServiceIds(DataTablesProviderInterface::DATATABLES_TAG_NAME);
40
        foreach ($providers as $id => $tag) {
41
            $manager->addMethodCall("addProvider", [new Reference($id)]);
42
        }
43
    }
44
}
45