Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#9)
by Jérémiah
09:17
created

OverblogGraphQLExtension::setServicesAliases()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 8
cts 8
cp 1
rs 9.6666
cc 3
eloc 5
nc 3
nop 2
crap 3
1
<?php
2
3
/*
4
 * This file is part of the OverblogGraphQLBundle package.
5
 *
6
 * (c) Overblog <http://github.com/overblog/>
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 Overblog\GraphQLBundle\DependencyInjection;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
17
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
18
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
19
20
class OverblogGraphQLExtension extends Extension implements PrependExtensionInterface
21
{
22 31
    public function load(array $configs, ContainerBuilder $container)
23
    {
24 31
        $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
25 31
        $loader->load('services.yml');
26 31
        $loader->load('graphql_types.yml');
27 31
        $loader->load('graphql_fields.yml');
28 31
        $loader->load('graphql_args.yml');
29
30 31
        $configuration = $this->getConfiguration($configs, $container);
31 31
        $config = $this->processConfiguration($configuration, $configs);
32
33 31
        $this->setServicesAliases($config, $container);
34 31
        $this->setSchemaBuilderArguments($config, $container);
35 31
        $this->setSchemaArguments($config, $container);
36 31
        $this->setErrorHandlerArguments($config, $container);
37 31
        $this->setGraphiQLTemplate($config, $container);
38 31
    }
39
40 31
    public function prepend(ContainerBuilder $container)
41
    {
42 31
        $configs = $container->getExtensionConfig($this->getAlias());
43 31
        $configs = $container->getParameterBag()->resolveValue($configs);
44 31
        $configuration = $this->getConfiguration($configs, $container);
45 31
        $config = $this->processConfiguration($configuration, $configs);
46
47
        /** @var OverblogGraphQLTypesExtension $typesExtension */
48 31
        $typesExtension = $container->getExtension($this->getAlias().'_types');
49 31
        $typesExtension->containerPrependExtensionConfig($config, $container);
50 31
    }
51
52 31
    private function setGraphiQLTemplate(array $config, ContainerBuilder $container)
53
    {
54 31
        if (isset($config['templates']['graphiql'])) {
55 31
            $container->setParameter('overblog_graphql.graphiql_template', $config['templates']['graphiql']);
56 31
        }
57 31
    }
58
59 31
    private function setErrorHandlerArguments(array $config, ContainerBuilder $container)
60
    {
61 31
        if (isset($config['definitions']['internal_error_message'])) {
62
            $container
63
                ->getDefinition($this->getAlias().'.error_handler')
64
                ->replaceArgument(0, $config['definitions']['internal_error_message'])
65
                ->setPublic(true)
66
            ;
67
        }
68 31
    }
69
70 31
    private function setSchemaBuilderArguments(array $config, ContainerBuilder $container)
71
    {
72 31
        $container->getDefinition($this->getAlias().'.schema_builder')
73 31
            ->replaceArgument(1, $config['definitions']['config_validation']);
74 31
    }
75
76 31
    private function setSchemaArguments(array $config, ContainerBuilder $container)
77
    {
78 31
        if (isset($config['definitions']['schema'])) {
79
            $container
80 31
                ->getDefinition($this->getAlias().'.schema')
81 31
                ->replaceArgument(0, $config['definitions']['schema']['query'])
82 31
                ->replaceArgument(1, $config['definitions']['schema']['mutation'])
83 31
                ->replaceArgument(2, $config['definitions']['schema']['subscription'])
84 31
                ->setPublic(true)
85
            ;
86 31
        }
87 31
    }
88
89 31
    private function setServicesAliases(array $config, ContainerBuilder $container)
90
    {
91 31
        if (isset($config['services'])) {
92 31
            foreach ($config['services'] as $name => $id) {
93 31
                $alias = sprintf('%s.%s', $this->getAlias(), $name);
94 31
                $container->setAlias($alias, $id);
95 31
            }
96 31
        }
97 31
    }
98
99 31
    public function getAlias()
100
    {
101 31
        return 'overblog_graphql';
102
    }
103
104 31
    public function getConfiguration(array $config, ContainerBuilder $container)
105
    {
106 31
        return new Configuration($container->getParameter('kernel.debug'));
107
    }
108
}
109