Comment ajoute-t-on une méthode dans un repository ?
Bonsoir, comment ajoute t'on un méthode dans une classe repository?
j'ai essayer de faire un test simple:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<?php
namespace Kod\CatalogueBundle\Entity;
use Doctrine\ORM\EntityRepository;
/**
* ArticleRepository
*
* This class was generated by the Doctrine ORM. Add your own custom
* repository methods below.
*/
class ArticleRepository extends EntityRepository {
public function test()
{
echo "je suis un test";
}
} |
j'essaye d'appeller la méthode test()
voici mon controller:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
<?php
namespace Kod\CatalogueBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Kod\CatalogueBundle\Entity\ArticleRepository;
use Kod\CatalogueBundle\Entity\Article;
class MoteurController extends Controller {
public function rechercheArticleAction($article) {
$repository = $this->getDoctrine()
->getEntityManager()
->getRepository('KodCatalogueBundle:Article')->test();
// Reste de la méthode du contrôleur.
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of RechercheController
*
* @author keokod
*/
?> |
le controlleur me dit
[code}
Undefined method 'test'. The method name must start with either findBy or findOneBy!
[/code]
comment je dois m'y prendre pour afficher
je suis un test ??
je vous remercie d'avance pour la réponse :)