2727use ApiPlatform \Metadata \Property \Factory \PropertyMetadataFactoryInterface ;
2828use ApiPlatform \Metadata \Property \Factory \PropertyNameCollectionFactoryInterface ;
2929use ApiPlatform \Metadata \Resource \ResourceMetadataCollection ;
30- use ApiPlatform \Metadata \ResourceClassResolverInterface ;
31- use ApiPlatform \Metadata \Util \TypeHelper ;
30+ use ApiPlatform \Metadata \Util \ResourceClassInfoTrait ;
3231use ApiPlatform \OpenApi \Model \Parameter as OpenApiParameter ;
3332use ApiPlatform \Serializer \Filter \FilterInterface as SerializerFilterInterface ;
3433use ApiPlatform \State \Parameter \ValueCaster ;
4443 */
4544final class ParameterResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface
4645{
46+ use ResourceClassInfoTrait;
4747 use StateOptionsTrait;
4848
4949 private array $ localPropertyCache = [];
@@ -55,7 +55,6 @@ public function __construct(
5555 private readonly ?ContainerInterface $ filterLocator = null ,
5656 private readonly ?NameConverterInterface $ nameConverter = null ,
5757 private readonly ?LoggerInterface $ logger = null ,
58- private readonly ?ResourceClassResolverInterface $ resourceClassResolver = null ,
5958 ) {
6059 }
6160
@@ -121,7 +120,7 @@ private function getProperties(string $resourceClass, ?Parameter $parameter = nu
121120 }
122121
123122 if (!$ isLastPart ) {
124- $ nextClass = $ this ->getClassFromProperty ($ propertyMetadata );
123+ $ nextClass = $ this ->getClassNameFromProperty ($ propertyMetadata );
125124
126125 if (!$ nextClass ) {
127126 break ;
@@ -167,30 +166,6 @@ private function getProperties(string $resourceClass, ?Parameter $parameter = nu
167166 return $ this ->localPropertyCache [$ k ];
168167 }
169168
170- private function getClassFromProperty (ApiProperty $ propertyMetadata ): ?string
171- {
172- if (!($ type = $ propertyMetadata ->getNativeType ())) {
173- return null ;
174- }
175-
176- $ className = $ this ->extractClassNameFromType ($ type );
177-
178- if ($ className && $ this ->resourceClassResolver ?->isResourceClass($ className )) {
179- return $ className ;
180- }
181-
182- return null ;
183- }
184-
185- private function extractClassNameFromType (Type $ type ): ?string
186- {
187- if ($ collectionValueType = TypeHelper::getCollectionValueType ($ type )) {
188- return TypeHelper::getClassName ($ collectionValueType );
189- }
190-
191- return TypeHelper::getClassName ($ type );
192- }
193-
194169 private function getDefaultParameters (Operation $ operation , string $ resourceClass , int &$ internalPriority ): Parameters
195170 {
196171 $ propertyNames = $ properties = [];
0 commit comments