We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
27 | class AutoMappingPass implements CompilerPassInterface |
||
28 | { |
||
29 | private static $serviceSubclassTagMapping = [ |
||
30 | MutationInterface::class => 'overblog_graphql.mutation', |
||
31 | ResolverInterface::class => 'overblog_graphql.resolver', |
||
32 | Type::class => 'overblog_graphql.type', |
||
33 | ]; |
||
34 | |||
35 | 14 | public function process(ContainerBuilder $container) |
|
36 | { |
||
37 | 14 | $enabled = $container->getParameter('overblog_graphql.auto_mapping.enabled'); |
|
38 | // enabled auto mapping for all bundles and custom dirs ? |
||
39 | 14 | if ($enabled) { |
|
40 | 1 | $directories = $container->getParameter('overblog_graphql.auto_mapping.directories'); |
|
41 | 1 | $bundles = $container->getParameter('kernel.bundles'); |
|
42 | 1 | $directories = array_merge( |
|
43 | 1 | array_map( |
|
44 | 1 | function ($class) { |
|
45 | 1 | $bundleDir = $this->bundleDir($class); |
|
46 | |||
47 | 1 | return $bundleDir.'/GraphQL'; |
|
48 | 1 | }, |
|
49 | $bundles |
||
50 | 1 | ), |
|
51 | $directories |
||
52 | 1 | ); |
|
53 | // add app dir |
||
54 | 1 | if ($container->hasParameter('kernel.root_dir')) { |
|
55 | 1 | $directories[] = $container->getParameter('kernel.root_dir').'/GraphQL'; |
|
56 | 1 | } |
|
57 | 1 | } else { |
|
58 | // enabled auto mapping only for this bundle |
||
59 | 13 | $directories = [$this->bundleDir(OverblogGraphQLBundle::class).'/GraphQL']; |
|
60 | } |
||
61 | 14 | $directoryList = []; |
|
62 | |||
63 | 14 | foreach ($directories as $directory) { |
|
64 | 14 | list($reflectionClasses, $directories) = $this->reflectionClassesFromDirectory($directory); |
|
65 | 14 | $directoryList = array_merge($directoryList, $directories); |
|
66 | 14 | $this->addServicesDefinitions($container, $reflectionClasses); |
|
67 | 14 | } |
|
68 | |||
69 | 14 | foreach ($directoryList as $directory => $v) { |
|
70 | 14 | $directory = realpath($directory); |
|
71 | 14 | $container->addResource(new DirectoryResource($directory, '/\.php$/')); |
|
72 | 14 | } |
|
73 | 14 | } |
|
74 | |||
75 | /** |
||
76 | * @param ContainerBuilder $container |
||
77 | * @param \ReflectionClass[] $reflectionClasses |
||
78 | */ |
||
79 | 14 | private function addServicesDefinitions(ContainerBuilder $container, array $reflectionClasses) |
|
85 | |||
86 | 14 | private function addServiceDefinition(ContainerBuilder $container, \ReflectionClass $reflectionClass) |
|
97 | |||
98 | 14 | private function addDefinitionTags(Definition $definition, \ReflectionClass $reflectionClass) |
|
125 | |||
126 | 14 | private function addDefinitionTagsFromAliasesMethod(Definition $definition, $className, $tagName, $withMethod) |
|
138 | |||
139 | 14 | private function subclass($class) |
|
151 | |||
152 | /** |
||
153 | * Gets the classes reflection of class in the given directory. |
||
154 | * |
||
155 | * @param string $directory |
||
156 | * |
||
157 | * @return array |
||
158 | */ |
||
159 | 14 | private function reflectionClassesFromDirectory($directory) |
|
205 | |||
206 | 14 | private function bundleDir($bundleClass) |
|
213 | } |
||
214 |