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; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\FileLocator; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
17
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class YnloGraphQLExtension |
21
|
|
|
*/ |
22
|
|
|
class YnloGraphQLExtension extends Extension |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public function load(array $configs, ContainerBuilder $container) |
28
|
|
|
{ |
29
|
|
|
$configuration = new Configuration($container->getParameter('kernel.debug')); |
|
|
|
|
30
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
31
|
|
|
|
32
|
|
|
if (!isset($config['definitions']['extensions']['namespaces']['bundles']['aliases']['GraphQLBundle'])) { |
33
|
|
|
$config['definitions']['extensions']['namespaces']['bundles']['aliases']['GraphQLBundle'] = 'AppBundle'; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
$container->setParameter('graphql.config', $config); |
37
|
|
|
if (isset($config['definitions']['extensions'])) { |
38
|
|
|
foreach ($config['definitions']['extensions'] as $extension => $config) { |
39
|
|
|
$config = isset($config['enabled']) && $config['enabled'] ? $config : []; |
40
|
|
|
$container->setParameter('graphql.extension_config.'.$extension, $config ?? []); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
$configDir = __DIR__.'/../Resources/config'; |
45
|
|
|
$loader = new YamlFileLoader($container, new FileLocator($configDir)); |
46
|
|
|
$loader->load('services.yml'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritDoc} |
51
|
|
|
*/ |
52
|
|
|
public function getAlias() |
53
|
|
|
{ |
54
|
|
|
return 'graphql'; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.