Segue abaixo o erro
[Tue Nov 1 11:50:57 2022] [::1]:55668 [500]: GET /buscarCursosEmJson - Uncaught Error: Class "Alura\Cursos\Controller\Response" not found in /home/anonymous/Projects/alura/gerenciador-de-cursos/src/Controller/CursosEmJson.php:31
Stack trace:
#0 /home/anonymous/Projects/alura/gerenciador-de-cursos/public/index.php(43): Alura\Cursos\Controller\CursosEmJson->handle()
#1 {main}
thrown in /home/anonymous/Projects/alura/gerenciador-de-cursos/src/Controller/CursosEmJson.php on line 31
Segue abaixo a linha de código:
<?php
namespace Alura\Cursos\Controller;
use Psr\Http\Message\ResponseInterface;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectRepository;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Alura\Cursos\Entity\Curso;
class CursosEmJson implements RequestHandlerInterface
{
/**
* @var ObjectRepository
*/
private $repositorioDeCursos;
public function __construct(EntityManagerInterface $entityManager)
{
$this->repositorioDeCursos = $entityManager
->getRepository(Curso::class);
}
public function handle(ServerRequestInterface $request): ResponseInterface
{
$cursos = $this->repositorioDeCursos->findAll();
return new Response(
200, json_encode($cursos)
);
}
}