1

In a bundle I'm developing and was working correctly I added a new functionality which involves adding a repository to the entity. Now, when I execute the newly added method I get the following error:

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

The newly added code is:

Controller:

/**
 * 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;
}

Repository:

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();
    }
}

That's all that has changed... if any more code is needed for clarification I will post it.

So could anybody tell me what I'm doing wrong? I couldn't find anything neither on SO nor on Google.

Thanks in advance

Michi
  • 2,480
  • 3
  • 28
  • 38
  • Maybe could be usefull for you: http://stackoverflow.com/questions/11686922/symfony2-1-mapping-error-class-parents/11691357#11691357 – unairoldan Jul 27 '12 at 19:26

1 Answers1

4

I just found the error myself... the line

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

has to be

$tree = $em->getRepository('CmsBundle:CmsPages')->loadTree();
Michi
  • 2,480
  • 3
  • 28
  • 38