Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/Symfony/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use ApiPlatform\Exception\FilterValidationException;
use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle;
use Doctrine\ORM\EntityManagerInterface;
Expand Down Expand Up @@ -558,10 +560,9 @@ private function addDefaultsSection(ArrayNodeDefinition $rootNode): void
return $normalizedDefaults;
});

$reflection = new \ReflectionClass(ApiResource::class);
foreach ($reflection->getConstructor()->getParameters() as $parameter) {
$defaultsNode->children()->variableNode($nameConverter->normalize($parameter->getName()));
}
$this->defineDefault($defaultsNode, new \ReflectionClass(ApiResource::class), $nameConverter);
$this->defineDefault($defaultsNode, new \ReflectionClass(Put::class), $nameConverter);
$this->defineDefault($defaultsNode, new \ReflectionClass(Post::class), $nameConverter);
}

private function addMakerSection(ArrayNodeDefinition $rootNode): void
Expand All @@ -573,4 +574,11 @@ private function addMakerSection(ArrayNodeDefinition $rootNode): void
->end()
->end();
}

private function defineDefault(ArrayNodeDefinition $defaultsNode, \ReflectionClass $reflectionClass, CamelCaseToSnakeCaseNameConverter $nameConverter)
{
foreach ($reflectionClass->getConstructor()->getParameters() as $parameter) {
$defaultsNode->children()->variableNode($nameConverter->normalize($parameter->getName()));
}
}
}