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

ControllerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 16
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0

1 Method

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