Skip to content

Commit e34953a

Browse files
authored
Merge pull request #66 from mcg-web/debug_info
Add debug info
2 parents 5c920d5 + a057352 commit e34953a

36 files changed

+237
-94
lines changed

Config/EnumTypeDefinition.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ public function getDefinition()
2727
->useAttributeAsKey('name')
2828
->prototype('array')
2929
->beforeNormalization()
30-
->ifTrue(function ($v) { return !is_null($v) && !is_array($v); })
31-
->then(function ($v) { return ['value' => $v]; })
30+
->ifTrue(function ($v) {
31+
return !is_null($v) && !is_array($v);
32+
})
33+
->then(function ($v) {
34+
return ['value' => $v];
35+
})
3236
->end()
3337
->isRequired()
3438
->children()

Config/ObjectTypeDefinition.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public function getDefinition()
3737

3838
$node->validate()
3939
->ifTrue(function ($v) {
40-
4140
return array_key_exists('fieldsDefaultAccess', $v) && null !== $v['fieldsDefaultAccess'];
4241
})
4342
->then(function ($v) {

DependencyInjection/Configuration.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Configuration implements ConfigurationInterface
3030
*/
3131
public function __construct($debug)
3232
{
33-
$this->debug = (Boolean) $debug;
33+
$this->debug = (bool) $debug;
3434
}
3535

3636
public function getConfigTreeBuilder()
@@ -44,6 +44,7 @@ public function getConfigTreeBuilder()
4444
->addDefaultsIfNotSet()
4545
->children()
4646
->scalarNode('internal_error_message')->defaultNull()->end()
47+
->booleanNode('show_debug_info')->defaultValue(false)->end()
4748
->booleanNode('config_validation')->defaultValue($this->debug)->end()
4849
->arrayNode('schema')
4950
->beforeNormalization()
@@ -84,11 +85,11 @@ public function getConfigTreeBuilder()
8485
->arrayNode('exceptions')
8586
->children()
8687
->arrayNode('warnings')
87-
->treatNullLike(array())
88+
->treatNullLike([])
8889
->prototype('scalar')->end()
8990
->end()
9091
->arrayNode('errors')
91-
->treatNullLike(array())
92+
->treatNullLike([])
9293
->prototype('scalar')->end()
9394
->end()
9495
->arrayNode('types')
@@ -174,12 +175,18 @@ private function addSecurityQuerySection($name, $disabledValue)
174175
$node
175176
->info('Disabled if equal to false.')
176177
->beforeNormalization()
177-
->ifTrue(function ($v) { return false === $v; })
178-
->then(function () use ($disabledValue) { return $disabledValue; })
178+
->ifTrue(function ($v) {
179+
return false === $v;
180+
})
181+
->then(function () use ($disabledValue) {
182+
return $disabledValue;
183+
})
179184
->end()
180185
->defaultFalse()
181186
->validate()
182-
->ifTrue(function ($v) { return $v < 0; })
187+
->ifTrue(function ($v) {
188+
return $v < 0;
189+
})
183190
->thenInvalid('"overblog_graphql.security.'.$name.'" must be greater or equal to 0.')
184191
->end()
185192
;

DependencyInjection/OverblogGraphQLExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function load(array $configs, ContainerBuilder $container)
4040
$this->setConfigBuilders($config);
4141
$this->setVersions($config, $container);
4242

43+
$container->getDefinition('overblog_graphql.request_executor')->replaceArgument(3, $config['definitions']['show_debug_info']);
4344
$container->setParameter($this->getAlias().'.resources_dir', realpath(__DIR__.'/../Resources'));
4445
}
4546

@@ -161,7 +162,8 @@ public function getConfiguration(array $config, ContainerBuilder $container)
161162
* Returns a list of custom exceptions mapped to error/warning classes.
162163
*
163164
* @param array $exceptionConfig
164-
* @return array Custom exception map, [exception => UserError/UserWarning].
165+
*
166+
* @return array Custom exception map, [exception => UserError/UserWarning]
165167
*/
166168
private function buildExceptionMap(array $exceptionConfig)
167169
{

DependencyInjection/OverblogGraphQLTypesExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ private function typesConfigsMappingFromConfig(array $config, ContainerBuilder $
105105
if (!empty($config['definitions']['mappings']['types'])) {
106106
$typesMappings = array_filter(array_map(
107107
function (array $typeMapping) use ($container) {
108-
109108
$params = $this->detectConfigFiles($container, $typeMapping['dir'], $typeMapping['type']);
110109

111110
return $params;

DependencyInjection/TypesConfiguration.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ function ($type) {
115115

116116
private function addBeforeNormalization(ArrayNodeDefinition $node)
117117
{
118-
$typeKeyExists = function ($types) { return !empty($types) && is_array($types); };
118+
$typeKeyExists = function ($types) {
119+
return !empty($types) && is_array($types);
120+
};
119121

120122
$node
121123
// set type config.name
@@ -147,7 +149,9 @@ private function addBeforeNormalization(ArrayNodeDefinition $node)
147149
->end()
148150
// normalized relay-mutation-payload
149151
->beforeNormalization()
150-
->ifTrue(function ($types) { return !empty($types) && is_array($types); })
152+
->ifTrue(function ($types) {
153+
return !empty($types) && is_array($types);
154+
})
151155
->then($this->relayNormalizer('relay-mutation-payload', 'Overblog\GraphQLBundle\Relay\Mutation\PayloadDefinition'))
152156
->end();
153157
}

Error/ErrorHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,13 @@ public function handleErrors(ExecutionResult $executionResult, $throwRawExceptio
139139
* that is displayed to the user.
140140
*
141141
* @param \Exception $rawException
142+
*
142143
* @return \Exception
143144
*/
144145
protected function convertException(\Exception $rawException = null)
145146
{
146147
if (null === $rawException) {
147-
return null;
148+
return;
148149
}
149150

150151
if (!empty($this->exceptionMap[get_class($rawException)])) {

ExpressionLanguage/AuthorizationExpressionProvider.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public function getFunctions()
2424
function ($role) {
2525
return sprintf('$container->get(\'security.authorization_checker\')->isGranted(%s)', $role);
2626
},
27-
function () {}
27+
function () {
28+
}
2829
),
2930

3031
new ExpressionFunction(
@@ -34,39 +35,44 @@ function ($roles) {
3435

3536
return $code;
3637
},
37-
function () {}
38+
function () {
39+
}
3840
),
3941

4042
new ExpressionFunction(
4143
'isAnonymous',
4244
function () {
4345
return '$container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_ANONYMOUSLY\')';
4446
},
45-
function () {}
47+
function () {
48+
}
4649
),
4750

4851
new ExpressionFunction(
4952
'isRememberMe',
5053
function () {
5154
return '$container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_REMEMBERED\')';
5255
},
53-
function () {}
56+
function () {
57+
}
5458
),
5559

5660
new ExpressionFunction(
5761
'isFullyAuthenticated',
5862
function () {
5963
return '$container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_FULLY\')';
6064
},
61-
function () {}
65+
function () {
66+
}
6267
),
6368

6469
new ExpressionFunction(
6570
'isAuthenticated',
6671
function () {
6772
return '$container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_REMEMBERED\') || $container->get(\'security.authorization_checker\')->isGranted(\'IS_AUTHENTICATED_FULLY\')';
6873
},
69-
function () {}
74+
function () {
75+
}
7076
),
7177

7278
new ExpressionFunction(
@@ -76,7 +82,8 @@ function ($object, $permission) {
7682

7783
return $code;
7884
},
79-
function () {}
85+
function () {
86+
}
8087
),
8188

8289
new ExpressionFunction(
@@ -86,7 +93,8 @@ function ($object, $permissions) {
8693

8794
return $code;
8895
},
89-
function () {}
96+
function () {
97+
}
9098
),
9199
];
92100
}

ExpressionLanguage/ConfigExpressionProvider.php

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,35 @@ public function getFunctions()
2525
function ($value) {
2626
return sprintf('$container->get(%s)', $value);
2727
},
28-
function () {}
28+
function () {
29+
}
2930
),
3031

3132
new ExpressionFunction(
3233
'parameter',
3334
function ($value) {
3435
return sprintf('$container->getParameter(%s)', $value);
3536
},
36-
function () {}
37+
function () {
38+
}
3739
),
3840

3941
new ExpressionFunction(
4042
'isTypeOf',
4143
function ($className) {
4244
return sprintf('($className = %s) && $value instanceof $className', $className);
4345
},
44-
function () {}
46+
function () {
47+
}
4548
),
4649

4750
new ExpressionFunction(
4851
'resolver',
4952
function ($alias, $args = '[]') {
5053
return sprintf('$container->get(\'overblog_graphql.resolver_resolver\')->resolve([%s, %s])', $alias, $args);
5154
},
52-
function () {}
55+
function () {
56+
}
5357
),
5458

5559
new ExpressionFunction(
@@ -60,7 +64,8 @@ function ($mutateAndGetPayload) {
6064

6165
return $code;
6266
},
63-
function () {}
67+
function () {
68+
}
6469
),
6570

6671
new ExpressionFunction(
@@ -71,7 +76,8 @@ function ($mutateAndGetPayload) {
7176

7277
return $code;
7378
},
74-
function () {}
79+
function () {
80+
}
7581
),
7682

7783
new ExpressionFunction(
@@ -82,7 +88,8 @@ function ($idFetcher) {
8288

8389
return $code;
8490
},
85-
function () {}
91+
function () {
92+
}
8693
),
8794

8895
new ExpressionFunction(
@@ -93,15 +100,17 @@ function ($resolveSingleInput) {
93100

94101
return $code;
95102
},
96-
function () {}
103+
function () {
104+
}
97105
),
98106

99107
new ExpressionFunction(
100108
'mutation',
101109
function ($alias, $args = '[]') {
102110
return sprintf('$container->get(\'overblog_graphql.mutation_resolver\')->resolve([%s, %s])', $alias, $args);
103111
},
104-
function () {}
112+
function () {
113+
}
105114
),
106115

107116
new ExpressionFunction(
@@ -115,7 +124,8 @@ function ($id, $typeName = null) {
115124
$id
116125
);
117126
},
118-
function () {}
127+
function () {
128+
}
119129
),
120130

121131
new ExpressionFunction(
@@ -126,15 +136,17 @@ function ($globalId) {
126136
$globalId
127137
);
128138
},
129-
function () {}
139+
function () {
140+
}
130141
),
131142

132143
new ExpressionFunction(
133144
'newObject',
134145
function ($className, $args = '[]') {
135146
return sprintf('(new \ReflectionClass(%s))->newInstanceArgs(%s)', $className, $args);
136147
},
137-
function () {}
148+
function () {
149+
}
138150
),
139151
];
140152
}

Generator/TypeGenerator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function setCacheDir($cacheDir)
5454

5555
protected function generateClassDocBlock(array $value)
5656
{
57-
return <<<EOF
57+
return <<<'EOF'
5858
5959
/**
6060
* THIS FIELD WAS GENERATED AND SHOULD NOT BE MODIFIED!
@@ -73,9 +73,10 @@ protected function resolveTypeCode($alias)
7373
}
7474

7575
/**
76-
* todo replace generateResolve in vendor after spec-april2016 is merged
76+
* todo replace generateResolve in vendor after spec-april2016 is merged.
7777
*
7878
* @param array $value
79+
*
7980
* @return string
8081
*/
8182
protected function generateResolve2(array $value)

0 commit comments

Comments
 (0)