19
19
use ApiPlatform \Exception \FilterValidationException ;
20
20
use ApiPlatform \Exception \InvalidArgumentException ;
21
21
use ApiPlatform \Metadata \ApiResource ;
22
+ use ApiPlatform \Metadata \Post ;
23
+ use ApiPlatform \Metadata \Put ;
22
24
use Doctrine \Bundle \DoctrineBundle \DoctrineBundle ;
23
25
use Doctrine \Bundle \MongoDBBundle \DoctrineMongoDBBundle ;
24
26
use Doctrine \ORM \EntityManagerInterface ;
@@ -558,10 +560,9 @@ private function addDefaultsSection(ArrayNodeDefinition $rootNode): void
558
560
return $ normalizedDefaults ;
559
561
});
560
562
561
- $ reflection = new \ReflectionClass (ApiResource::class);
562
- foreach ($ reflection ->getConstructor ()->getParameters () as $ parameter ) {
563
- $ defaultsNode ->children ()->variableNode ($ nameConverter ->normalize ($ parameter ->getName ()));
564
- }
563
+ $ this ->defineDefault ($ defaultsNode , new \ReflectionClass (ApiResource::class), $ nameConverter );
564
+ $ this ->defineDefault ($ defaultsNode , new \ReflectionClass (Put::class), $ nameConverter );
565
+ $ this ->defineDefault ($ defaultsNode , new \ReflectionClass (Post::class), $ nameConverter );
565
566
}
566
567
567
568
private function addMakerSection (ArrayNodeDefinition $ rootNode ): void
@@ -573,4 +574,11 @@ private function addMakerSection(ArrayNodeDefinition $rootNode): void
573
574
->end ()
574
575
->end ();
575
576
}
577
+
578
+ private function defineDefault (ArrayNodeDefinition $ defaultsNode , \ReflectionClass $ reflectionClass , CamelCaseToSnakeCaseNameConverter $ nameConverter )
579
+ {
580
+ foreach ($ reflectionClass ->getConstructor ()->getParameters () as $ parameter ) {
581
+ $ defaultsNode ->children ()->variableNode ($ nameConverter ->normalize ($ parameter ->getName ()));
582
+ }
583
+ }
576
584
}
0 commit comments