|
| 1 | +<?php |
| 2 | + |
| 3 | + |
| 4 | +namespace TheCodingMachine\Tdbm\Graphql\Bundle\DependencyInjection; |
| 5 | + |
| 6 | +use function class_exists; |
| 7 | +use Doctrine\Common\Annotations\AnnotationException; |
| 8 | +use Doctrine\Common\Annotations\AnnotationReader as DoctrineAnnotationReader; |
| 9 | +use Doctrine\Common\Annotations\AnnotationRegistry; |
| 10 | +use Doctrine\Common\Annotations\CachedReader; |
| 11 | +use Doctrine\Common\Cache\ApcuCache; |
| 12 | +use function function_exists; |
| 13 | +use GraphQL\Type\Definition\InputObjectType; |
| 14 | +use GraphQL\Type\Definition\ObjectType; |
| 15 | +use Psr\Container\ContainerInterface; |
| 16 | +use ReflectionClass; |
| 17 | +use function str_replace; |
| 18 | +use function strpos; |
| 19 | +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
| 20 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 21 | +use Symfony\Component\DependencyInjection\Definition; |
| 22 | +use Symfony\Component\DependencyInjection\Reference; |
| 23 | +use TheCodingMachine\GraphQLite\AnnotationReader; |
| 24 | +use TheCodingMachine\GraphQLite\Annotations\Mutation; |
| 25 | +use TheCodingMachine\GraphQLite\Annotations\Query; |
| 26 | +use TheCodingMachine\Graphqlite\Bundle\Mappers\ContainerFetcherTypeMapper; |
| 27 | +use TheCodingMachine\Graphqlite\Bundle\QueryProviders\ControllerQueryProvider; |
| 28 | +use TheCodingMachine\GraphQLite\FieldsBuilderFactory; |
| 29 | +use TheCodingMachine\GraphQLite\InputTypeGenerator; |
| 30 | +use TheCodingMachine\GraphQLite\InputTypeUtils; |
| 31 | +use TheCodingMachine\GraphQLite\Mappers\GlobTypeMapper; |
| 32 | +use TheCodingMachine\GraphQLite\Mappers\RecursiveTypeMapperInterface; |
| 33 | +use TheCodingMachine\GraphQLite\Mappers\StaticTypeMapper; |
| 34 | +use TheCodingMachine\GraphQLite\NamingStrategy; |
| 35 | +use TheCodingMachine\GraphQLite\TypeGenerator; |
| 36 | +use TheCodingMachine\GraphQLite\Types\MutableObjectType; |
| 37 | +use TheCodingMachine\GraphQLite\Types\ResolvableInputObjectType; |
| 38 | +use TheCodingMachine\TDBM\Configuration; |
| 39 | +use TheCodingMachine\Tdbm\GraphQL\GraphQLTypeAnnotator; |
| 40 | + |
| 41 | +/** |
| 42 | + * Detects controllers and types automatically and tag them. |
| 43 | + */ |
| 44 | +class TdbmGraphqlCompilerPass implements CompilerPassInterface |
| 45 | +{ |
| 46 | + /** |
| 47 | + * This Compiler pass adds the GraphQLTypeAnnotator to TDBM configuration |
| 48 | + */ |
| 49 | + public function process(ContainerBuilder $container) |
| 50 | + { |
| 51 | + $configuration = $container->findDefinition(Configuration::class); |
| 52 | + $arguments = $configuration->getArguments(); |
| 53 | + |
| 54 | + $generationListeners = $arguments[7] ?? []; |
| 55 | + $codeGenerationListeners = $arguments[9] ?? []; |
| 56 | + |
| 57 | + $generationListeners[] = new Reference(GraphQLTypeAnnotator::class); |
| 58 | + $codeGenerationListeners[] = new Reference(GraphQLTypeAnnotator::class); |
| 59 | + |
| 60 | + $configuration->setArgument(7, $generationListeners); |
| 61 | + $configuration->setArgument(9, $codeGenerationListeners); |
| 62 | + } |
| 63 | +} |
0 commit comments