We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
21 | class OverblogGraphQLExtension extends Extension implements PrependExtensionInterface |
||
22 | { |
||
23 | 9 | public function load(array $configs, ContainerBuilder $container) |
|
24 | { |
||
25 | 9 | $loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
|
26 | 9 | $loader->load('services.yml'); |
|
27 | 9 | $loader->load('graphql_types.yml'); |
|
28 | 9 | $loader->load('graphql_resolvers.yml'); |
|
29 | |||
30 | 9 | $config = $this->treatConfigs($configs, $container); |
|
31 | |||
32 | 9 | $this->setServicesAliases($config, $container); |
|
|
|||
33 | 9 | $this->setSchemaBuilderArguments($config, $container); |
|
34 | 9 | $this->setSchemaArguments($config, $container); |
|
35 | 9 | $this->setErrorHandlerArguments($config, $container); |
|
36 | 9 | $this->setGraphiQLTemplate($config, $container); |
|
37 | 9 | $this->setSecurity($config, $container); |
|
38 | 9 | $this->setConfigBuilders($config); |
|
39 | |||
40 | 9 | $container->setParameter($this->getAlias().'.resources_dir', realpath(__DIR__.'/../Resources')); |
|
41 | 9 | } |
|
42 | |||
43 | 8 | public function prepend(ContainerBuilder $container) |
|
44 | { |
||
45 | 8 | $configs = $container->getExtensionConfig($this->getAlias()); |
|
46 | 8 | $configs = $container->getParameterBag()->resolveValue($configs); |
|
47 | 8 | $config = $this->treatConfigs($configs, $container, true); |
|
48 | |||
49 | /** @var OverblogGraphQLTypesExtension $typesExtension */ |
||
50 | 8 | $typesExtension = $container->getExtension($this->getAlias().'_types'); |
|
51 | 8 | $typesExtension->containerPrependExtensionConfig($config, $container); |
|
52 | 8 | } |
|
53 | |||
54 | 9 | private function setConfigBuilders(array $config) |
|
55 | { |
||
56 | 9 | foreach (['args', 'field'] as $category) { |
|
57 | 9 | if (!empty($config['definitions']['builders'][$category])) { |
|
58 | 1 | $method = 'add'.ucfirst($category).'BuilderClass'; |
|
59 | |||
60 | 1 | foreach ($config['definitions']['builders'][$category] as $params) { |
|
61 | 1 | TypeWithOutputFieldsDefinition::$method($params['alias'], $params['class']); |
|
62 | 1 | } |
|
63 | 1 | } |
|
64 | 9 | } |
|
65 | 9 | } |
|
66 | |||
67 | 9 | private function treatConfigs(array $configs, ContainerBuilder $container, $forceReload = false) |
|
68 | { |
||
69 | 9 | static $config = null; |
|
70 | |||
71 | 9 | if ($forceReload || null === $config) { |
|
72 | 9 | $configuration = $this->getConfiguration($configs, $container); |
|
73 | 9 | $config = $this->processConfiguration($configuration, $configs); |
|
74 | 9 | } |
|
75 | |||
76 | 9 | return $config; |
|
77 | } |
||
78 | |||
79 | 9 | private function setSecurity(array $config, ContainerBuilder $container) |
|
84 | |||
85 | 9 | private function setGraphiQLTemplate(array $config, ContainerBuilder $container) |
|
89 | |||
90 | 9 | private function setErrorHandlerArguments(array $config, ContainerBuilder $container) |
|
99 | |||
100 | 9 | private function setSchemaBuilderArguments(array $config, ContainerBuilder $container) |
|
105 | |||
106 | 9 | private function setSchemaArguments(array $config, ContainerBuilder $container) |
|
118 | |||
119 | 9 | private function setServicesAliases(array $config, ContainerBuilder $container) |
|
128 | |||
129 | 9 | public function getAlias() |
|
133 | |||
134 | 9 | public function getConfiguration(array $config, ContainerBuilder $container) |
|
138 | } |
||
139 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.