【发布时间】:2012-07-20 10:40:39
【问题描述】:
在我正在开发且工作正常的捆绑包中,我添加了一项新功能,其中涉及向实体添加存储库。现在,当我执行新添加的方法时,出现以下错误:
警告:class_parents() [function.class-parents]:类 CmsPages 不存在,无法加载到 /Applications/MAMP/htdocs/symfony-standard-2.1/vendor/doctrine/common/lib/Doctrine/ Common/Persistence/Mapping/RuntimeReflectionService.php 第 40 行
新增代码为:
控制器:
/**
* Returns an json formated tree
*
* @Route("/getTree", name="admin_cmsPages_getTree", options={"expose"=true})
*/
public function getTreeAction()
{
$em = $this->getDoctrine()->getManager();
$tree = $em->getRepository('CmsPages')->loadTree();
$response = new Response(json_encode( $tree ));
$response->headers->set('Content-Type', 'application/json');
return $response;
}
存储库:
namespace Yanic\CmsBundle\Entity;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\NoResultException;
class CmsPagesRepository extends EntityRepository
{
public function loadTree()
{
$q = $this
->createQueryBuilder('p')
->select('p')
->orderBy( 'p.lft' )
->getQuery()
;
return $q->getArrayResult();
}
}
这就是所有的变化......如果需要更多代码来澄清,我会发布它。
那么谁能告诉我我做错了什么?我在 SO 和 Google 上都找不到任何东西。
提前致谢
【问题讨论】:
标签: php doctrine-orm symfony-2.1