| 1: | <?php |
| 2: | namespace TIC\TownBundle\Repository; |
| 3: | |
| 4: | use TIC\TownBundle\Entity\Departement as RepoEntity; |
| 5: | use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
| 6: | use Doctrine\Persistence\ManagerRegistry; |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | class DepartementRepository extends ServiceEntityRepository |
| 17: | { |
| 18: | |
| 19: | public function __construct(ManagerRegistry $registry) |
| 20: | { |
| 21: | parent::__construct($registry, RepoEntity::class); |
| 22: | } |
| 23: | |
| 24: | |
| 25: | public $sortBy = array('nom_maj' => 'ASC'); |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | public function searchBasic(string $term, ?int $limit=20) |
| 32: | { |
| 33: | return $this->createQueryBuilder('d') |
| 34: | ->select('d.insee AS id, d.nom AS text') |
| 35: | ->where('d.nom LIKE :term')->setParameter('term', '%'.$term.'%') |
| 36: | ->setMaxResults($limit) |
| 37: | ->getQuery()->getArrayResult() |
| 38: | ; |
| 39: | } |
| 40: | |
| 41: | } |
| 42: | |