Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony2 - Custom repository not found
    primarykey
    data
    text
    <p>I've this error:</p> <blockquote> <p>Fatal error: Class 'gsyle39\VideothequeBundle\Repository\GenreRepository' not found in C:\wamp\www\Videotheque\vendor\doctrine\lib\Doctrine\ORM\EntityManager.php on line 578</p> </blockquote> <p>Nevertheless, I add the name of the repository class to the mapping definition of my entity :</p> <pre><code>/** * gsyle39\VideoThequeBundle\Entity\Genre * * @ORM\Table() * * @ORM\Entity(repositoryClass="gsyle39\VideothequeBundle\Repository\GenreRepository") */ class Genre { ... } </code></pre> <p>Here is my GenreRepository : </p> <pre><code>&lt;?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-&gt;_em-&gt;createQueryBuilder('g') // leftJoin because I need all the genre -&gt;leftJoin('g.films', 'f') -&gt;addSelect('COUNT(f)') -&gt;groupBy('g') -&gt;getQuery() -&gt;getArrayResult(); // $genres contains all the genres and the associated movies return ($genres); } } </code></pre> <p>And finally this is the method in my controller I use for calling my custome "findALL" :</p> <pre><code>public function getListGenresAction(){ $liste_genres = $this-&gt;getDoctrine() -&gt;getEntityManager() -&gt;getRepository('gstyle39VideothequeBundle:Genre') -&gt;myFindAll; return $this-&gt;render('gstyle39VideothequeBundle:Videotheque:test.html.twig', array( 'genres' =&gt; $liste_genres )); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload