We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
18 | class Configuration implements ConfigurationInterface |
||
19 | { |
||
20 | public const NAME = 'overblog_graphql'; |
||
21 | |||
22 | /** bool */ |
||
23 | private $debug; |
||
24 | |||
25 | /** null|string */ |
||
26 | private $cacheDir; |
||
27 | |||
28 | /** |
||
29 | * Constructor. |
||
30 | * |
||
31 | * @param bool $debug Whether to use the debug mode |
||
32 | * @param null|string $cacheDir |
||
33 | */ |
||
34 | 33 | public function __construct(bool $debug, string $cacheDir = null) |
|
39 | |||
40 | 33 | public function getConfigTreeBuilder() |
|
41 | { |
||
42 | 33 | $treeBuilder = new TreeBuilder(self::NAME); |
|
43 | |||
44 | 33 | $rootNode = self::getRootNodeWithoutDeprecation($treeBuilder, self::NAME); |
|
45 | |||
46 | $rootNode |
||
47 | 33 | ->children() |
|
48 | 33 | ->append($this->batchingMethodSection()) |
|
49 | 33 | ->append($this->definitionsSection()) |
|
50 | 33 | ->append($this->errorsHandlerSection()) |
|
51 | 33 | ->append($this->servicesSection()) |
|
52 | 33 | ->append($this->securitySection()) |
|
53 | 33 | ->end(); |
|
54 | |||
55 | 33 | return $treeBuilder; |
|
56 | } |
||
57 | |||
58 | 33 | private function batchingMethodSection() |
|
59 | { |
||
60 | 33 | $builder = new TreeBuilder('batching_method', 'enum'); |
|
61 | /** @var EnumNodeDefinition $node */ |
||
62 | 33 | $node = self::getRootNodeWithoutDeprecation($builder, 'batching_method', 'enum'); |
|
63 | |||
64 | $node |
||
65 | 33 | ->values(['relay', 'apollo']) |
|
66 | 33 | ->defaultValue('relay') |
|
67 | 33 | ->end(); |
|
68 | |||
69 | 33 | return $node; |
|
70 | } |
||
71 | |||
72 | 33 | private function errorsHandlerSection() |
|
73 | { |
||
74 | 33 | $builder = new TreeBuilder('errors_handler'); |
|
75 | /** @var ArrayNodeDefinition $node */ |
||
76 | 33 | $node = self::getRootNodeWithoutDeprecation($builder, 'errors_handler'); |
|
77 | $node |
||
78 | 33 | ->treatFalseLike(['enabled' => false]) |
|
79 | 33 | ->treatTrueLike(['enabled' => true]) |
|
80 | 33 | ->treatNullLike(['enabled' => true]) |
|
81 | 33 | ->addDefaultsIfNotSet() |
|
82 | 33 | ->children() |
|
83 | 33 | ->booleanNode('enabled')->defaultTrue()->end() |
|
84 | 33 | ->scalarNode('internal_error_message')->defaultValue(ErrorHandler::DEFAULT_ERROR_MESSAGE)->end() |
|
85 | 33 | ->booleanNode('rethrow_internal_exceptions')->defaultFalse()->end() |
|
86 | 33 | ->booleanNode('debug')->defaultValue($this->debug)->end() |
|
87 | 33 | ->booleanNode('log')->defaultTrue()->end() |
|
88 | 33 | ->scalarNode('logger_service')->defaultValue(ErrorLoggerListener::DEFAULT_LOGGER_SERVICE)->end() |
|
89 | 33 | ->booleanNode('map_exceptions_to_parent')->defaultFalse()->end() |
|
90 | 33 | ->arrayNode('exceptions') |
|
91 | 33 | ->addDefaultsIfNotSet() |
|
92 | 33 | ->children() |
|
93 | 33 | ->arrayNode('warnings') |
|
94 | 33 | ->treatNullLike([]) |
|
95 | 33 | ->prototype('scalar')->end() |
|
96 | 33 | ->end() |
|
97 | 33 | ->arrayNode('errors') |
|
98 | 33 | ->treatNullLike([]) |
|
99 | 33 | ->prototype('scalar')->end() |
|
100 | 33 | ->end() |
|
101 | 33 | ->end() |
|
102 | 33 | ->end(); |
|
103 | |||
104 | 33 | return $node; |
|
105 | } |
||
106 | |||
107 | 33 | private function definitionsSection() |
|
108 | { |
||
109 | 33 | $builder = new TreeBuilder('definitions'); |
|
110 | /** @var ArrayNodeDefinition $node */ |
||
111 | 33 | $node = \method_exists($builder, 'getRootNode') ? $builder->getRootNode() : $builder->root('definitions'); |
|
112 | $node |
||
113 | 33 | ->addDefaultsIfNotSet() |
|
114 | 33 | ->children() |
|
115 | 33 | ->variableNode('default_resolver')->defaultValue([Resolver::class, 'defaultResolveFn'])->end() |
|
116 | 33 | ->scalarNode('class_namespace')->defaultValue('Overblog\\GraphQLBundle\\__DEFINITIONS__')->end() |
|
117 | 33 | ->scalarNode('cache_dir')->defaultNull()->end() |
|
118 | 33 | ->booleanNode('use_classloader_listener')->defaultTrue()->end() |
|
119 | 33 | ->booleanNode('auto_compile')->defaultTrue()->end() |
|
120 | 33 | ->booleanNode('show_debug_info')->info('Show some performance stats in extensions')->defaultFalse()->end() |
|
121 | 33 | ->booleanNode('config_validation')->defaultValue($this->debug)->end() |
|
122 | 33 | ->append($this->definitionsSchemaSection()) |
|
123 | 33 | ->append($this->definitionsMappingsSection()) |
|
124 | 33 | ->arrayNode('builders') |
|
125 | 33 | ->children() |
|
126 | 33 | ->append($this->builderSection('field')) |
|
127 | 33 | ->append($this->builderSection('args')) |
|
128 | 33 | ->end() |
|
129 | 33 | ->end() |
|
130 | |||
131 | 33 | ->end() |
|
132 | 33 | ->end(); |
|
133 | |||
134 | 33 | return $node; |
|
135 | } |
||
136 | |||
137 | 33 | private function servicesSection() |
|
160 | |||
161 | 33 | private function securitySection() |
|
162 | { |
||
163 | 33 | $builder = new TreeBuilder('security'); |
|
164 | /** @var ArrayNodeDefinition $node */ |
||
165 | 33 | $node = \method_exists($builder, 'getRootNode') ? $builder->getRootNode() : $builder->root('security'); |
|
166 | $node |
||
167 | 33 | ->addDefaultsIfNotSet() |
|
168 | 33 | ->children() |
|
169 | 33 | ->append($this->securityQuerySection('query_max_depth', QueryDepth::DISABLED)) |
|
170 | 33 | ->append($this->securityQuerySection('query_max_complexity', QueryComplexity::DISABLED)) |
|
171 | 33 | ->booleanNode('enable_introspection')->defaultTrue()->end() |
|
172 | 33 | ->booleanNode('handle_cors')->defaultFalse()->end() |
|
173 | 33 | ->end() |
|
174 | 33 | ->end(); |
|
175 | |||
176 | 33 | return $node; |
|
177 | } |
||
178 | |||
179 | 33 | private function definitionsSchemaSection() |
|
214 | |||
215 | 33 | private function definitionsMappingsSection() |
|
216 | { |
||
263 | |||
264 | /** |
||
265 | * @param string $name |
||
266 | * |
||
267 | * @return ArrayNodeDefinition |
||
268 | */ |
||
269 | 33 | private function builderSection($name) |
|
302 | |||
303 | /** |
||
304 | * @param string $name |
||
305 | * @param bool $disabledValue |
||
306 | * |
||
307 | * @return ScalarNodeDefinition |
||
308 | */ |
||
309 | 33 | private function securityQuerySection($name, $disabledValue) |
|
344 | |||
345 | /** |
||
346 | * @internal |
||
347 | * |
||
348 | * @param TreeBuilder $builder |
||
349 | * @param string|null $name |
||
350 | * @param string $type |
||
351 | * |
||
352 | * @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition |
||
353 | */ |
||
354 | 38 | public static function getRootNodeWithoutDeprecation(TreeBuilder $builder, string $name, string $type = 'array') |
|
359 | } |
||
360 |