1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Application\Api; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\EntityManager; |
8
|
|
|
use GraphQL\Doctrine\Types; |
9
|
|
|
use Laminas\ServiceManager\ServiceManager; |
10
|
|
|
use Psr\Container\ContainerInterface; |
11
|
|
|
|
12
|
|
|
class TypesFactory |
13
|
|
|
{ |
14
|
1 |
|
public function __invoke(ContainerInterface $container): Types |
15
|
|
|
{ |
16
|
1 |
|
$entityManager = $container->get(EntityManager::class); |
17
|
|
|
|
18
|
1 |
|
$invokables = [ |
19
|
1 |
|
Enum\UserRoleType::class, |
20
|
1 |
|
Input\CreateExportInputType::class, |
21
|
1 |
|
\Ecodev\Felix\Api\Input\PaginationInputType::class, |
22
|
1 |
|
MutationType::class, |
23
|
1 |
|
Output\GlobalPermissionsListType::class, |
24
|
1 |
|
Output\GlobalPermissionsType::class, |
25
|
1 |
|
\Ecodev\Felix\Api\Output\PermissionsType::class, |
26
|
1 |
|
QueryType::class, |
27
|
1 |
|
Scalar\LoginType::class, |
28
|
1 |
|
\Ecodev\Felix\Api\Scalar\EmailType::class, |
29
|
1 |
|
\Ecodev\Felix\Api\Scalar\ColorType::class, |
30
|
1 |
|
\Ecodev\Felix\Api\Scalar\UrlType::class, |
31
|
1 |
|
\GraphQL\Upload\UploadType::class, |
32
|
1 |
|
\Ecodev\Felix\Api\Scalar\ChronosType::class, |
33
|
1 |
|
]; |
34
|
|
|
|
35
|
1 |
|
$invokables = array_combine($invokables, $invokables); |
36
|
|
|
|
37
|
1 |
|
$aliases = [ |
38
|
1 |
|
'datetime' => \Ecodev\Felix\Api\Scalar\ChronosType::class, |
39
|
1 |
|
]; |
40
|
|
|
|
41
|
1 |
|
$aliasesWithShortVariant = [ |
42
|
1 |
|
\Cake\Chronos\Chronos::class => \Ecodev\Felix\Api\Scalar\ChronosType::class, |
|
|
|
|
43
|
1 |
|
\Psr\Http\Message\UploadedFileInterface::class => \GraphQL\Upload\UploadType::class, |
44
|
1 |
|
]; |
45
|
|
|
|
46
|
|
|
// Automatically add aliases and their short variants |
47
|
1 |
|
foreach ($aliasesWithShortVariant as $alias => $type) { |
48
|
1 |
|
$parts = explode('\\', $alias); |
49
|
1 |
|
$shortAlias = end($parts); |
50
|
|
|
|
51
|
1 |
|
$aliases[$alias] = $type; |
52
|
1 |
|
$aliases[$shortAlias] = $type; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Automatically add aliases for GraphQL type name from the invokable types |
56
|
1 |
|
foreach ($invokables as $type) { |
57
|
1 |
|
$parts = explode('\\', $type); |
58
|
1 |
|
$alias = preg_replace('~Type$~', '', end($parts)); |
59
|
1 |
|
$aliases[$alias] = $type; |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
$customTypes = new ServiceManager([ |
63
|
1 |
|
'invokables' => $invokables, |
64
|
1 |
|
'aliases' => $aliases, |
65
|
1 |
|
'services' => [ |
66
|
|
|
// // This is not quite right because it allow to compare a string with a json array. |
67
|
|
|
// // TODO: either hide the json filter or find a cleaner solution |
68
|
1 |
|
'json' => \GraphQL\Type\Definition\Type::string(), |
69
|
1 |
|
], |
70
|
1 |
|
'abstract_factories' => [ |
71
|
1 |
|
\Ecodev\Felix\Api\Output\PaginationTypeFactory::class, |
72
|
1 |
|
\Ecodev\Felix\Api\Enum\EnumAbstractFactory::class, |
73
|
1 |
|
], |
74
|
1 |
|
]); |
75
|
|
|
|
76
|
1 |
|
$types = new Types($entityManager, $customTypes); |
77
|
|
|
|
78
|
1 |
|
return $types; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths