3
我有此错误:Symfony2的 - 没有找到自定义库
Fatal error: Class 'gsyle39\VideothequeBundle\Repository\GenreRepository' not found in C:\wamp\www\Videotheque\vendor\doctrine\lib\Doctrine\ORM\EntityManager.php on line 578
不过,我想补充库类的名称,以我的实体的映射定义:
/**
* gsyle39\VideoThequeBundle\Entity\Genre
*
* @ORM\Table()
*
* @ORM\Entity(repositoryClass="gsyle39\VideothequeBundle\Repository\GenreRepository")
*/
class Genre
{
...
}
这里是我的GenreRepository:
<?php
namespace gstyle39\VideothequeBundle\Entity;
use Doctrine\ORM\EntityRepository;
/**
* GenreRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class GenreRepository extends EntityRepository
{
public function myfindAll()
{
$genres = $this->_em->createQueryBuilder('g')
// leftJoin because I need all the genre
->leftJoin('g.films', 'f')
->addSelect('COUNT(f)')
->groupBy('g')
->getQuery()
->getArrayResult();
// $genres contains all the genres and the associated movies
return ($genres);
}
}
最后,这是我用于调用我的custome“findALL”的控制器中的方法:
public function getListGenresAction(){
$liste_genres = $this->getDoctrine()
->getEntityManager()
->getRepository('gstyle39VideothequeBundle:Genre')
->myFindAll;
return $this->render('gstyle39VideothequeBundle:Videotheque:test.html.twig', array(
'genres' => $liste_genres
));
}
你是对的,我有一个错误的命名空间,但它不能解决问题:s – 2012-07-31 14:37:32
尝试删除'app/cache/*'文件夹并重新加载应用程序。 – Florent 2012-07-31 15:12:08
不起作用:s – 2012-07-31 15:15:02