【发布时间】:2012-10-06 21:50:59
【问题描述】:
如何使用最新的 Symfony 和 Doctrine 从控制器内部获取实体管理器?
“The Book”中描述的方式现在被标记为已弃用。什么是现代(正确)方法?
public function someAction()
{
// getEntityManager() from Doctrine\Bundle\DoctrineBundle\Registry is deprecated
$entityManager = $this->getDoctrine()->getEntityManager();
...
}
【问题讨论】:
-
其实我直到最近才知道弃用的方法,它在 symfony2 调试页面中被标记为警告,它还告诉我应该使用什么新方法。所以我猜大多数时候你会在调试页面中找到答案。
标签: symfony controller doctrine-orm