Symfony 2中的2级实体文件夹

时间:2012-09-09 02:41:32

标签: symfony doctrine-orm

我在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():类CommonBundle \ Entity \ EntityA没有   存在且无法加载

2 个答案:

答案 0 :(得分:21)

这是CommonBundle:EntityFolder1\EntityA

答案 1 :(得分:1)

使用您实体的完整班级名称:

$product = $this->getDoctrine()
                ->getRepository('Acme\CommonBundle\Entity\EntityFolder1\EntityA')
                ->find(1);