Psr7RequestValueResolver.php in Drupal 9
File
core/lib/Drupal/Core/Controller/ArgumentResolver/Psr7RequestValueResolver.php
View source
<?php
namespace Drupal\Core\Controller\ArgumentResolver;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
final class Psr7RequestValueResolver implements ArgumentValueResolverInterface {
protected $httpMessageFactory;
public function __construct(HttpMessageFactoryInterface $http_message_factory) {
$this->httpMessageFactory = $http_message_factory;
}
public function supports(Request $request, ArgumentMetadata $argument) {
return $argument
->getType() == ServerRequestInterface::class;
}
public function resolve(Request $request, ArgumentMetadata $argument) {
(yield $this->httpMessageFactory
->createRequest($request));
}
}