Php Symfony2-致命错误:调用未定义的方法Symfony\Bundle\DoctrineBundle\Registry::getManager()

Php Symfony2-致命错误:调用未定义的方法Symfony\Bundle\DoctrineBundle\Registry::getManager(),php,symfony,doctrine-orm,Php,Symfony,Doctrine Orm,我试图调用条令管理器在数据库中持久化对象,但出现以下错误: 错误: Fatal error: Call to undefined method Symfony\Bundle\DoctrineBundle\Registry::getManager() 代码: 出现此错误的原因是什么?如果您正在使用控制器 $em = $this->get("doctrine.orm.entity_manager") 如果你在服役 @doctrine.orm.entity_manager 如果你在使用

我试图调用条令管理器在数据库中持久化对象,但出现以下错误:

错误:

Fatal error: Call to undefined method Symfony\Bundle\DoctrineBundle\Registry::getManager()
代码:


出现此错误的原因是什么?

如果您正在使用控制器

$em = $this->get("doctrine.orm.entity_manager")  
如果你在服役

@doctrine.orm.entity_manager

如果你在使用控制器

$em = $this->get("doctrine.orm.entity_manager")  
如果你在服役

@doctrine.orm.entity_manager

如果您在控制器中,如果您在服务中,请使用$em=$this->getdoctor.orm.entity\u管理器inject@doctor.orm.entity_manager@johnSmith完美的正是我想要的。请给我一个答案,这样我就可以接受了!只是想知道他们是否更改了$this->getDoctrine->getManger的代码?这一周前对我有效。@Populus,有趣的是,它昨天对我有效,而我今天做了一些事情,所以我认为这是我造成的。但这让我觉得这可能是一个更新…如果您在控制器中,请使用$em=$this->getdoctor.orm.entity\u管理器如果您在服务中,请使用inject@doctor.orm.entity_manager@johnSmith完美的正是我想要的。请给我一个答案,这样我就可以接受了!只是想知道他们是否更改了$this->getDoctrine->getManger的代码?这一周前对我有效。@Populus,有趣的是,它昨天对我有效,而我今天做了一些事情,所以我认为这是我造成的。但这让我觉得这可能是一个更新。。。