Completed
Push — master ( 998494...8e3b13 )
by Rafael
10s
created

ControllerPass::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 12
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 9
nc 3
nop 1
crap 12
1
<?php
2
3
/*******************************************************************************
4
 *  This file is part of the GraphQL Bundle package.
5
 *
6
 *  (c) YnloUltratech <[email protected]>
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 Ynlo\GraphQLBundle\DependencyInjection\Compiler;
13
14
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Ynlo\GraphQLBundle\Controller\ExplorerController;
17
18
class ControllerPass implements CompilerPassInterface
19
{
20
    public function process(ContainerBuilder $container)
21
    {
22
        $config = $container->getParameter('graphql.graphiql');
23
        $providerId = $container->getParameter('graphql.graphiql_auth_provider');
24
        $provider = null;
25
26
        if ($providerId) {
27
            $provider = $container->getDefinition($providerId);
28
        } elseif ($config['authentication']['required']) {
29
            throw new \RuntimeException('Configure a valid provider to use GraphiQL with authentication.');
30
        }
31
32
        $controllerDefinition = $container->getDefinition(ExplorerController::class);
33
        $controllerDefinition->setArgument(1, $provider);
34
    }
35
}
36