11

我在 Symfony2 包中有一个两级实体文件夹:

CommonBundle/Entity/EntityFolder1/EntityA.php
CommonBundle/Entity/EntityFolder2
CommonBundle/Entity/EntityFolder3
CommonBundle/Entity/EntityFolder4

当我尝试获取位于其中一个文件夹中的实体的存储库时:

$product = $this->getDoctrine()->getRepository('CommonBundle:EntityA')->find(1); 

Symfony 不承认这一点CommonBundle:EntityA

我也试过了CommonBundle:EntityFolder1:EntityA

警告:class_parents(): Class CommonBundle\Entity\EntityA 不存在,无法加载

4

2 回答 2

21

CommonBundle:EntityFolder1\EntityA

于 2012-09-09T09:19:46.823 回答
1

使用实体的完整类名:

$product = $this->getDoctrine()
                ->getRepository('Acme\CommonBundle\Entity\EntityFolder1\EntityA')
                ->find(1);
于 2012-09-09T07:29:45.893 回答