2012-07-21 44 views
1

在我正在開發並正在正常工作的包中,我添加了一個新功能,其中包含向實體添加存儲庫。現在,當我執行新添加的方法我收到以下錯誤:實體/存儲庫中的Class_parents錯誤

Warning: class_parents() [function.class-parents]: Class CmsPages does not exist and could not be loaded in /Applications/MAMP/htdocs/symfony-standard-2.1/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php line 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上都找不到任何東西。

在此先感謝

+0

也許能對您有用: HTTP ://stackoverflow.com/questions/11686922/symfony2-1-mapping-error-class-parents/11691357#11691357 – unairoldan 2012-07-27 19:26:52

回答

4

我剛剛發現錯誤自己...行

$tree = $em->getRepository('CmsPages')->loadTree(); 

必須

$tree = $em->getRepository('CmsBundle:CmsPages')->loadTree();