<?php
declare(strict_types=1);
namespace Overblog\GraphQLBundle\EventListener;
use Overblog\GraphQLBundle\Event\ExecutorContextEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
final class RequestFilesListener
{
private RequestStack $requestStack;
public function __construct(RequestStack $requestStack)
{
$this->requestStack = $requestStack;
}
public function onExecutorContextEvent(ExecutorContextEvent $event): void
{
$request = $this->requestStack->getCurrentRequest();
if (!$request instanceof Request) {
return;
}
$context = $event->getExecutorContext();
$context['request'] = $request;
$context['request_files'] = $request->files;
}
}