Answer the question
In order to leave comments, you need to log in
Why is the object not being deleted?
I'm trying to delete a record from the database, but I've run into a problem.
They make it clear to me that there is no "remove" method
Undefined method 'remove'. The method name must start with either findBy or findOneBy!
class VoteHandler implements VoteHandlerInterface{
private $om;
private $entityClass;
private $repository;
private $formFactory;
public function __construct(ObjectManager $om, $entityClass, FormFactoryInterface $formFactory){
$this->om = $om;
$this->entityClass = $entityClass;
$this->repository = $this->om->getRepository($this->entityClass);
$this->formFactory = $formFactory;
}
public function delete($id){
$vote = $this->repository->findOneById($id);
$this->repository->remove($vote);
$this->repository->flush();
return true;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question