|
46 | 46 | use ApiPlatform\Symfony\Routing\Router; |
47 | 47 | use ApiPlatform\Symfony\Routing\SkolemIriConverter; |
48 | 48 | use Negotiation\Negotiator; |
| 49 | +use phpDocumentor\Reflection\DocBlockFactory; |
| 50 | +use phpDocumentor\Reflection\Types\ContextFactory; |
| 51 | +use PHPStan\PhpDocParser\Parser\PhpDocParser; |
| 52 | +use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor; |
| 53 | +use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor; |
| 54 | +use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; |
| 55 | +use Symfony\Component\PropertyInfo\PropertyInfoCacheExtractor; |
| 56 | +use Symfony\Component\PropertyInfo\PropertyInfoExtractor; |
49 | 57 | use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory; |
50 | 58 | use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; |
51 | 59 |
|
|
68 | 76 |
|
69 | 77 | $services->alias('api_platform.property_accessor', 'property_accessor'); |
70 | 78 |
|
71 | | - $services->alias('api_platform.property_info', 'property_info'); |
| 79 | + $services->set('api_platform.property_info.reflection_extractor', ReflectionExtractor::class) |
| 80 | + ->tag('property_info.list_extractor', ['priority' => -1000]) |
| 81 | + ->tag('property_info.type_extractor', ['priority' => -1002]) |
| 82 | + ->tag('property_info.access_extractor', ['priority' => -1000]) |
| 83 | + ->tag('property_info.initializable_extractor', ['priority' => -1000]); |
| 84 | + |
| 85 | + if (class_exists(DocBlockFactory::class)) { |
| 86 | + $services->set('api_platform.property_info.php_doc_extractor', PhpDocExtractor::class) |
| 87 | + ->tag('property_info.description_extractor', ['priority' => -1000]) |
| 88 | + ->tag('property_info.type_extractor', ['priority' => -1001]); |
| 89 | + } |
| 90 | + |
| 91 | + if (class_exists(PhpDocParser::class) && class_exists(ContextFactory::class)) { |
| 92 | + $services->set('api_platform.property_info.phpstan_extractor', PhpStanExtractor::class) |
| 93 | + ->tag('property_info.type_extractor', ['priority' => -1000]); |
| 94 | + } |
| 95 | + |
| 96 | + $services->set('api_platform.property_info', PropertyInfoExtractor::class) |
| 97 | + ->args([ |
| 98 | + tagged_iterator('property_info.list_extractor'), |
| 99 | + tagged_iterator('property_info.type_extractor'), |
| 100 | + tagged_iterator('property_info.description_extractor'), |
| 101 | + tagged_iterator('property_info.access_extractor'), |
| 102 | + tagged_iterator('property_info.initializable_extractor'), |
| 103 | + ]); |
| 104 | + |
| 105 | + $services->set('api_platform.property_info.cache', PropertyInfoCacheExtractor::class) |
| 106 | + ->decorate('api_platform.property_info') |
| 107 | + ->args([ |
| 108 | + service('.inner'), |
| 109 | + service('cache.property_info'), |
| 110 | + ]); |
72 | 111 |
|
73 | 112 | $services->set('api_platform.negotiator', Negotiator::class); |
74 | 113 |
|
|
0 commit comments