for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ApiPlatform\Core\Bridge\Symfony\Bundle\ArgumentResolver;
use ApiPlatform\Core\Util\RequestAttributesExtractor;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
class PayloadArgumentResolver implements ArgumentValueResolverInterface
{
public function supports(Request $request, ArgumentMetadata $argument): bool
if ($argument->isVariadic()) {
return false;
}
$class = $argument->getType();
if (null === $class) {
if (null === $request->attributes->get('data')) {
$attributes = RequestAttributesExtractor::extractAttributes($request);
if ($attributes['resource_class'] === $class) {
return true;
return is_subclass_of($attributes['resource_class'], $class);
public function resolve(Request $request, ArgumentMetadata $argument): \Generator
if (!$this->supports($request, $argument)) {
throw new \InvalidArgumentException('Given request and argument not supported.');
yield $request->attributes->get('data');