如何在另一个包 symfony 2 中调用一个包实体查询
How to call One bundle entity query in another bundle symfony 2
我在我的 symfony 2 项目中添加了两个包。
1) Api 捆绑包
2)项目包。
项目包包含成员实体。我想访问此实体以在 API 捆绑包控制器中为成员设置登录。但是当我试图访问它时,我遇到了错误。
未知实体命名空间别名 'TestProjectBundle'。
$rsmember = $this->getDoctrine()
->getRepository('TestProjectBundle:Member')
->findOneBy(array('email' => $email));
如何在我的 API 包中调用它??
你应该使用 BundleLogicalName:EntityName
调用实体,因为你有 ProjectBundle
所以你应该调用它:
$rsmember = $this->getDoctrine()
->getRepository('ProjectBundle:Member')
->findOneBy(array('email' => $email));
The AppBundle:Product string is a shortcut you can use anywhere in
Doctrine instead of the full class name of the entity (i.e.
AppBundle\Entity\Product). As long as your entity lives under the
Entity namespace of your bundle, this will work.
勾选doc
我在我的 symfony 2 项目中添加了两个包。 1) Api 捆绑包 2)项目包。 项目包包含成员实体。我想访问此实体以在 API 捆绑包控制器中为成员设置登录。但是当我试图访问它时,我遇到了错误。 未知实体命名空间别名 'TestProjectBundle'。
$rsmember = $this->getDoctrine()
->getRepository('TestProjectBundle:Member')
->findOneBy(array('email' => $email));
如何在我的 API 包中调用它??
你应该使用 BundleLogicalName:EntityName
调用实体,因为你有 ProjectBundle
所以你应该调用它:
$rsmember = $this->getDoctrine()
->getRepository('ProjectBundle:Member')
->findOneBy(array('email' => $email));
The AppBundle:Product string is a shortcut you can use anywhere in Doctrine instead of the full class name of the entity (i.e. AppBundle\Entity\Product). As long as your entity lives under the Entity namespace of your bundle, this will work.
勾选doc