Completed
Push — master ( 583713...989906 )
by WEBEWEB
05:28
created

JQueryDataTablesCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 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 compiler pass.
22
 *
23
 * @author webeweb <https://github.com/webeweb/>
24
 * @package WBW\Bundle\JQuery\DatatablesBundle\DependencyInjection\Compiler
25
 * @final
26
 */
27
final class JQueryDataTablesCompilerPass implements CompilerPassInterface {
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function process(ContainerBuilder $container) {
33
34
        // Check if the storage manager is defined.
35
        if (false === $container->has(DataTablesManager::SERVICE_NAME)) {
36
            return;
37
        }
38
39
        // Get the storage manager.
40
        $manager = $container->findDefinition(DataTablesManager::SERVICE_NAME);
41
42
        // Find all service IDs with DataTables provider tag.
43
        $providers = $container->findTaggedServiceIds(DataTablesProviderInterface::TAG_NAME);
44
45
        // Register each provider.
46
        foreach ($providers as $id => $tag) {
47
            $manager->addMethodCall("registerProvider", [new Reference($id)]);
48
        }
49
    }
50
51
}
52