Commit 09744fb2 by Julien Jorry

Add twig function for presta search

parent 9a1f209f
......@@ -23,6 +23,24 @@ class PrestataireRepository extends ServiceEntityRepository
parent::__construct($registry, Prestataire::class);
}
/**
* @return Prestataire[] Returns an array of Prestataire objects
*/
public function findDefault($orderBy = 'raison', $direction = 'ASC', $limit = null)
{
$qb = $this->createQueryBuilder('p');
$qb = $this->addDefaultFilter($qb);
$qb->orderBy('p.'.$orderBy, $direction);
if ($limit != null) {
$qb->limit($limit);
}
return $qb
->getQuery()
->getResult()
;
}
public function getPrestataireMLC()
{
if ($this->_em->getFilters()->isEnabled('enabled_filter')) {
......@@ -45,11 +63,9 @@ class PrestataireRepository extends ServiceEntityRepository
$qb
->leftJoin('p.etats', 't')
->andWhere('p.mlc = :mlc')
// ->andWhere('p.acceptemlc = :acceptemlc')
->andWhere('p.enabled = :enabled')
->andWhere('t.enabled != :disabled OR t.enabled IS NULL')
->setParameter('mlc', false)
// ->setParameter('acceptemlc', true)
->setParameter('enabled', true)
->setParameter('disabled', false)
;
......@@ -123,6 +139,8 @@ class PrestataireRepository extends ServiceEntityRepository
}
/**
* For Prestataire Admin search
*
* @return Prestataire[] Returns an array of Prestataire objects
*/
public function findByGroupeLocal(Groupe $groupe)
......
......@@ -235,9 +235,9 @@ class AppExtension extends AbstractExtension
return $this->em->getRepository(News::class)->findBy(['enabled' => true], ['createdAt' => 'DESC'], $limit);
}
public function getAllPrestataires()
public function getAllPrestataires($orderBy = 'raison', $direction = 'ASC', $limit = null)
{
return $this->em->getRepository(Prestataire::class)->findBy(['mlc' => false, 'enabled' => true], ['raison' => 'ASC']);
return $this->em->getRepository(Prestataire::class)->findDefault($orderBy, $direction, $limit);
}
public function getAllGroupePrestataires($type = '')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment