We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php |
||
| 19 | class OverblogGraphQLExtension extends Extension implements PrependExtensionInterface |
||
| 20 | { |
||
| 21 | 25 | public function load(array $configs, ContainerBuilder $container) |
|
| 44 | 25 | ||
| 45 | public function prepend(ContainerBuilder $container) |
||
| 46 | 23 | { |
|
| 47 | $configs = $container->getExtensionConfig($this->getAlias()); |
||
| 48 | 23 | $configs = $container->getParameterBag()->resolveValue($configs); |
|
| 49 | 23 | $config = $this->treatConfigs($configs, $container, true); |
|
| 50 | 23 | ||
| 51 | /** @var OverblogGraphQLTypesExtension $typesExtension */ |
||
| 52 | $typesExtension = $container->getExtension($this->getAlias().'_types'); |
||
| 53 | 23 | $typesExtension->containerPrependExtensionConfig($config, $container); |
|
| 54 | 23 | } |
|
| 55 | 23 | ||
| 56 | public function getAlias() |
||
| 60 | |||
| 61 | public function getConfiguration(array $config, ContainerBuilder $container) |
||
| 68 | |||
| 69 | private function setClassLoaderListener(array $config, ContainerBuilder $container) |
||
| 70 | 25 | { |
|
| 71 | $container->setParameter($this->getAlias().'.use_classloader_listener', $config['definitions']['use_classloader_listener']); |
||
| 72 | 25 | if ($config['definitions']['use_classloader_listener']) { |
|
| 73 | 25 | $definition = $container->setDefinition( |
|
| 74 | 23 | $this->getAlias().'.event_listener.classloader_listener', |
|
| 75 | 23 | new Definition(ClassLoaderListener::class) |
|
| 76 | 23 | ); |
|
| 77 | $definition->setArguments([new Reference($this->getAlias().'.cache_compiler')]); |
||
| 78 | 23 | $definition->addTag('kernel.event_listener', ['event' => 'kernel.request', 'method' => 'load', 'priority' => 255]); |
|
| 79 | 23 | $definition->addTag('kernel.event_listener', ['event' => 'console.command', 'method' => 'load', 'priority' => 255]); |
|
| 80 | 23 | } |
|
| 81 | } |
||
| 82 | 25 | ||
| 83 | private function setDefinitionParameters(array $config, ContainerBuilder $container) |
||
| 84 | 25 | { |
|
| 85 | // auto mapping |
||
| 86 | $container->setParameter($this->getAlias().'.auto_mapping.enabled', $config['definitions']['auto_mapping']['enabled']); |
||
| 87 | 25 | $container->setParameter($this->getAlias().'.auto_mapping.directories', $config['definitions']['auto_mapping']['directories']); |
|
| 88 | 25 | // generator and config |
|
| 89 | $container->setParameter($this->getAlias().'.default_resolver', $config['definitions']['default_resolver']); |
||
| 90 | 25 | $container->setParameter($this->getAlias().'.class_namespace', $config['definitions']['class_namespace']); |
|
| 91 | 25 | $container->setParameter($this->getAlias().'.cache_dir', $config['definitions']['cache_dir']); |
|
| 92 | 25 | } |
|
| 93 | 25 | ||
| 94 | private function setBatchingMethod(array $config, ContainerBuilder $container) |
||
| 95 | 25 | { |
|
| 96 | $container->setParameter($this->getAlias().'.batching_method', $config['batching_method']); |
||
| 97 | 25 | } |
|
| 98 | 25 | ||
| 99 | private function setExpressionLanguageDefaultParser(ContainerBuilder $container) |
||
| 100 | 25 | { |
|
| 101 | $class = version_compare(Kernel::VERSION, '3.2.0', '>=') ? ArrayAdapter::class : ArrayParserCache::class; |
||
| 102 | 25 | $definition = new Definition($class); |
|
| 103 | 25 | $definition->setPublic(false); |
|
| 104 | 25 | $container->setDefinition($this->getAlias().'.cache_expression_language_parser.default', $definition); |
|
| 105 | 25 | } |
|
| 106 | 25 | ||
| 107 | private function setShowDebug(array $config, ContainerBuilder $container) |
||
| 108 | 25 | { |
|
| 109 | $container->getDefinition($this->getAlias().'.request_executor')->replaceArgument(4, $config['definitions']['show_debug_info']); |
||
| 110 | 25 | } |
|
| 111 | 25 | ||
| 112 | private function setVersions(array $config, ContainerBuilder $container) |
||
| 113 | 25 | { |
|
| 114 | foreach ($config['versions'] as $key => $version) { |
||
| 115 | 25 | $container->setParameter(sprintf('%s.versions.%s', $this->getAlias(), $key), $version); |
|
| 116 | 25 | } |
|
| 117 | } |
||
| 118 | 25 | ||
| 119 | private function setConfigBuilders(array $config, ContainerBuilder $container) |
||
| 120 | 25 | { |
|
| 121 | $useObjectToAddResource = method_exists($container, 'addObjectResource'); |
||
| 122 | 25 | $objectToAddResourceMethod = $useObjectToAddResource ? 'addObjectResource' : 'addClassResource'; |
|
| 123 | 25 | ||
| 124 | foreach (['args', 'field'] as $category) { |
||
| 125 | 25 | if (!empty($config['definitions']['builders'][$category])) { |
|
| 126 | 25 | $method = 'add'.ucfirst($category).'BuilderClass'; |
|
| 127 | 1 | ||
| 128 | foreach ($config['definitions']['builders'][$category] as $params) { |
||
| 129 | 1 | $object = $useObjectToAddResource ? $params['class'] : new \ReflectionClass($params['class']); |
|
| 130 | 1 | $container->$objectToAddResourceMethod($object); |
|
| 131 | 1 | TypeWithOutputFieldsDefinition::$method($params['alias'], $params['class']); |
|
| 132 | 25 | } |
|
| 133 | } |
||
| 134 | } |
||
| 135 | } |
||
| 136 | 25 | ||
| 137 | private function treatConfigs(array $configs, ContainerBuilder $container, $forceReload = false) |
||
| 148 | |||
| 149 | private function setSecurity(array $config, ContainerBuilder $container) |
||
| 150 | 25 | { |
|
| 151 | foreach ($config['security'] as $key => $value) { |
||
| 152 | 25 | $container->setParameter(sprintf('%s.%s', $this->getAlias(), $key), $value); |
|
| 153 | 25 | } |
|
| 154 | } |
||
| 155 | 25 | ||
| 156 | private function setErrorHandlerArguments(array $config, ContainerBuilder $container) |
||
| 157 | 25 | { |
|
| 172 | 25 | ||
| 173 | 25 | private function setSchemaBuilderArguments(array $config, ContainerBuilder $container) |
|
| 178 | |||
| 179 | 25 | private function setSchemaArguments(array $config, ContainerBuilder $container) |
|
| 196 | 20 | ||
| 197 | private function setServicesAliases(array $config, ContainerBuilder $container) |
||
| 206 | 25 | ||
| 207 | 25 | /** |
|
| 208 | 25 | * Returns a list of custom exceptions mapped to error/warning classes. |
|
| 209 | * |
||
| 210 | * @param array $exceptionConfig |
||
| 211 | 25 | * |
|
| 212 | * @return array Custom exception map, [exception => UserError/UserWarning] |
||
| 213 | */ |
||
| 214 | private function buildExceptionMap(array $exceptionConfig) |
||
| 231 | } |
||
| 232 |
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.