I’m new to symfony, I’m trying to build a little web projet and I met an error on my symfony
interface.
I get this error while I want laugh my web project :
EntityManager#remove() expects parameter 1 to be an entity object, NULL given.
And here is the related code :
public function homepage(EntityManagerInterface $em)
{
$productRepository = $em->getRepository(Product::class);
$product = $productRepository->find(3);
$em->remove($product);
$em->flush();
dd($product);
return $this->render('home.html.twig');
}
}
Someone can help me to fix it ?
I tried to change the value setting of the $product but nothing happens.