bonjour,

j'ai créé un repository d'un entité "Produit" afin d’accéder à des requêtes personnalisé depuis le contrôleur.


j'ai ce message d'erreur :
n exception has been thrown during the rendering of a template ("Undefined method 'myActifFind'. The method name must start with either findBy or findOneBy!"

entité Produit.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
/**
* @ORM\Entity(repositoryClass="Acme\ProduitBundle\Repository\ProduitRepository")
*/
class Produit
{
    /**

mon repository:
...Bundle/Repository/ProduitRepository.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
<?php
namespace Acme\ProduitBundle\Repository;
use Doctrine\ORM\EntityRepository;
 
class ProduitRepository extends EntityRepository {    
    public function myActifFind($iduser) {
            $query = $this->createQueryBuilder('p')
            ->where('p.fUser=:iduser')
            ->setParameter('iduser', $iduser)
            ->andWhere('p.etat=1 OR p.etat=2')        
            ->orderBy('p.etat', 'ASC')
            ->getQuery();
            $lesProduits = $query->getResult();   
        return $lesProduits;
    }
}

dans mon controleur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
             $lesProduits = $this->getDoctrine()
            ->getEntityManager()
            ->getRepository('AcmeProduitBundle:Produit')
            ->myActifFind($user->getId());


j'ai suivie 2 tutos différents et je ne vois pas ou j'ai fais d'erreur.


merci pour votre aide