我想从PersistentCollection中删除线程实体:
//ThreadController.php
public function delete(Category $category, Thread $thread, Request $request): Response
{
if ($this->isCsrfTokenValid('delete'.$thread->getId(), $request->request->get('_token'))) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->remove($thread);
$entityManager->flush();
}
return $this->redirectToRoute('category_read', [
'slug' => $category->getSlug(),
]);
}
线程与类别具有ManyToOne关系。
但是,例如:
Thread One with id 1
Thread Two with id 2
Thread Three with id 3
..并且我正在尝试删除Thread One
,DELETE
操作没有发生。与Thread Two
相同。可以删除最新的实体(Thread Three in this case
)。
这种行为的原因可能是什么?谢谢