0
respostas

Declaração do __construct da classe BaseController com erro.

Olá meu caro! Podes me ajudar nessa?

Arquivo : Controller\BaseController.php:

<?php

namespace App\Controller;

use Doctrine\Common\Persistence\ObjectRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;

abstract class BaseController extends AbstractController
{

    /**
     * @var ObjectRepository
    */
    private $repository;

    /////////////////////////////////////////////////////
    // recebendo informações genéricas pelo construct. //
    /////////////////////////////////////////////////////
    //
    public function __construct(ObjectRepository $repository)//Com erro aqui
    {
        $this->repository = $repository;
    }

    public function buscarTodos():Response
    {
        $entityList = $this->repository->findAll();

        return new JsonResponse($entityList);
    }
}

Arquivo : Controller\MedicosController.php:

<?php

namespace App\Controller;

use App\Controller\BaseController;
use App\Repository\MedicosRepository;
use App\Utils\MedicoFactory;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class MedicosController extends BaseController
{

    /**
     * @var EntityManagerInterface
    */
    private $entityManager;

    /**
     * @var MedicoFactory
    */
    private $medicoFactory;

    /**
     * @var MedicosRepository
    */
    private $repository;

    public function __construct(
        EntityManagerInterface $entityManager,
        MedicoFactory $medicoFactory,
        MedicosRepository $repository
    ){
        parent::__construct($repository);//com erro aqui
        $this->entityManager = $entityManager;
        $this->medicoFactory = $medicoFactory;
        $this->medicosRepository = $repository;
    }

Retorno em tela do erro:

Insira aqui a descrição dessa imagem para ajudar na acessibilidade