Bonjour! Je suis entrain de suivre la formation de GrafiKart concernant Symfony. Je suis bloqué quelque part quand j'essai de récupérer les donnes. Voici le message d'erreur:
Cannot autowire service "App\Controller\PropertyController": argument "$em" of method "__construct()" references interface "Doctrine\Persistence\ObjectManager" but no such service exists. You should maybe alias this interface to the existing "doctrine.orm.default_entity_manager" service.
Mon controller
<?php
namespace App\Controller;
use App\Entity\Property;
use App\Repository\PropertyRepository;
use Doctrine\Persistence\ObjectManager;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class PropertyController extends AbstractController
{
/**
* @var PropertyRepository
*/
private $repository;
/**
* @var ObjectManager
*/
public function __construct(PropertyRepository $repository, ObjectManager $em)
{
$this->repository = $repository;
$this->em = $em;
}
/**
* @Route("/biens", name="property.index")
* @return Response
*/
public function index():Response
{
/*insersion des données dans la base via le controller.
$property = new Property();
$property->setTitle('Mon premier bien')
->setPrice(4000)
->setRooms(4)
->setBedrooms(3)
->setDescription('Une pièce que nous avons')
->setSurface(60)
->setFloor(4)
->setHeat(1)
->setCity('Lubumbashi')
->setAddress('16/Munongo/Maman YEMO/Mont-Ngafula')
->setPostalCode('34000');
$em = $this->getDoctrine()->getManager();
$em->persist($property);
$em->flush();
*/
$repository = $this->repository->findAllVisible();
$repository[0]->setSold(true);
$this->em->flush();
return $this->render('property/index.html.twig', [
'current_menu' => 'properties'
]);
}
}
Ce que je veux
Que ce problème soit résolu
Ce que j'obtiens
Message d'erreur