Skip to content

Commit e9ccb23

Browse files
authored
Merge pull request #21 from moufmouf/support_autowiring_annotation
Removing settings for enabling autowiring
2 parents cd1122e + a0e79d4 commit e9ccb23

File tree

5 files changed

+11
-41
lines changed

5 files changed

+11
-41
lines changed

DependencyInjection/Configuration.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ public function getConfigTreeBuilder()
3737
->booleanNode('RETHROW_UNSAFE_EXCEPTIONS')->defaultTrue()->info('Exceptions that do not implement ClientAware interface are not caught by the engine and propagated to Symfony.')->end()
3838
->end()
3939
->end()
40-
->arrayNode('autowire')
41-
->children()
42-
->booleanNode('by_class_name')->defaultTrue()->info('Autowire services based on the parameter\'s fully qualified class name')->end()
43-
->booleanNode('by_parameter_name')->defaultFalse()->info('Autowire services based on the parameter\'s name')->end()
44-
->end()
45-
->end()
4640
;
4741

4842
return $treeBuilder;

DependencyInjection/GraphqliteCompilerPass.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ public function process(ContainerBuilder $container)
7979
$controllersNamespaces = $container->getParameter('graphqlite.namespace.controllers');
8080
$typesNamespaces = $container->getParameter('graphqlite.namespace.types');
8181

82-
$autowireByParameterName = $container->getParameter('graphqlite.autowire.by_parameter_name');
83-
$autowireByClassName = $container->getParameter('graphqlite.autowire.by_class_name');
84-
8582
// 2 seconds of TTL in environment mode. Otherwise, let's cache forever!
8683
$env = $container->getParameter('kernel.environment');
8784
$globTtl = null;
@@ -127,17 +124,15 @@ public function process(ContainerBuilder $container)
127124
}
128125
}
129126

130-
if ($autowireByParameterName || $autowireByClassName) {
131-
foreach ($controllersNamespaces as $controllersNamespace) {
132-
foreach ($this->getClassList($controllersNamespace) as $className => $refClass) {
133-
$this->makePublicInjectedServices($refClass, $reader, $container, $autowireByClassName, $autowireByParameterName);
134-
}
127+
foreach ($controllersNamespaces as $controllersNamespace) {
128+
foreach ($this->getClassList($controllersNamespace) as $className => $refClass) {
129+
$this->makePublicInjectedServices($refClass, $reader, $container);
135130
}
131+
}
136132

137-
foreach ($typesNamespaces as $typeNamespace) {
138-
foreach ($this->getClassList($typeNamespace) as $className => $refClass) {
139-
$this->makePublicInjectedServices($refClass, $reader, $container, $autowireByClassName, $autowireByParameterName);
140-
}
133+
foreach ($typesNamespaces as $typeNamespace) {
134+
foreach ($this->getClassList($typeNamespace) as $className => $refClass) {
135+
$this->makePublicInjectedServices($refClass, $reader, $container);
141136
}
142137
}
143138

@@ -224,14 +219,14 @@ public function process(ContainerBuilder $container)
224219
}
225220
}
226221

227-
private function makePublicInjectedServices(ReflectionClass $refClass, AnnotationReader $reader, ContainerBuilder $container, bool $autowireByClassName, bool $autowireByParameterName): void
222+
private function makePublicInjectedServices(ReflectionClass $refClass, AnnotationReader $reader, ContainerBuilder $container): void
228223
{
229-
$services = $this->getCodeCache()->get($refClass, function() use ($refClass, $reader, $container, $autowireByClassName, $autowireByParameterName) {
224+
$services = $this->getCodeCache()->get($refClass, function() use ($refClass, $reader, $container) {
230225
$services = [];
231226
foreach ($refClass->getMethods() as $method) {
232227
$field = $reader->getRequestAnnotation($method, AbstractRequest::class);
233228
if ($field !== null) {
234-
$services += $this->getListOfInjectedServices($method, $container, $autowireByClassName, $autowireByParameterName);
229+
$services += $this->getListOfInjectedServices($method, $container);
235230
}
236231
}
237232
return $services;
@@ -248,7 +243,7 @@ private function makePublicInjectedServices(ReflectionClass $refClass, Annotatio
248243
* @param ContainerBuilder $container
249244
* @return array<string, string> key = value = service name
250245
*/
251-
private function getListOfInjectedServices(ReflectionMethod $method, ContainerBuilder $container, bool $autowireByClassName, bool $autowireByParameterName): array
246+
private function getListOfInjectedServices(ReflectionMethod $method, ContainerBuilder $container): array
252247
{
253248
$services = [];
254249

DependencyInjection/GraphqliteExtension.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,9 @@ public function load(array $configs, ContainerBuilder $container)
5454
$namespaceType = [];
5555
}
5656

57-
if (isset($configs[0]['autowire']['by_class_name'])) {
58-
$autowireByClassName = $configs[0]['autowire']['by_class_name'];
59-
} else {
60-
$autowireByClassName = true;
61-
}
62-
if (isset($configs[0]['autowire']['by_parameter_name'])) {
63-
$autowireByParameterName = $configs[0]['autowire']['by_parameter_name'];
64-
} else {
65-
$autowireByParameterName = false;
66-
}
67-
6857
$container->setParameter('graphqlite.namespace.controllers', $namespaceController);
6958
$container->setParameter('graphqlite.namespace.types', $namespaceType);
7059

71-
$container->setParameter('graphqlite.autowire.by_class_name', $autowireByClassName);
72-
$container->setParameter('graphqlite.autowire.by_parameter_name', $autowireByParameterName);
73-
7460
$loader->load('graphqlite.xml');
7561

7662
$definition = $container->getDefinition(ServerConfig::class);

Resources/config/container/graphqlite.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535

3636
<service id="TheCodingMachine\GraphQLite\Mappers\Parameters\ContainerParameterMapper">
3737
<argument type="service" id="service_container" />
38-
<argument>%graphqlite.autowire.by_class_name%</argument>
39-
<argument>%graphqlite.autowire.by_parameter_name%</argument>
4038
<tag name="graphql.parameter_mapper" />
4139
</service>
4240

Tests/GraphqliteTestingKernel.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ public function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
4141
'controllers' => ['TheCodingMachine\\Graphqlite\\Bundle\\Tests\\Fixtures\\Controller\\'],
4242
'types' => ['TheCodingMachine\\Graphqlite\\Bundle\\Tests\\Fixtures\\Types\\', 'TheCodingMachine\\Graphqlite\\Bundle\\Tests\\Fixtures\\Entities\\']
4343
],
44-
'autowire' => [
45-
'by_parameter_name' => true
46-
]
4744
));
4845
});
4946
$confDir = $this->getProjectDir().'/Tests/Fixtures/config';

0 commit comments

Comments
 (0)