Ejemplo n.º 1
0
 /**
  * Apply a filter for a filter_locale type.
  *
  * This method should work whih both ORM and DBAL query builder.
  */
 public function filterTextLike(ApplyFilterEvent $event)
 {
     $qb = $event->getQueryBuilder();
     $expr = $event->getFilterQuery()->getExpressionBuilder();
     $values = $event->getValues();
     if ('' !== $values['value'] && null !== $values['value']) {
         if (isset($values['condition_pattern'])) {
             $qb->andWhere($expr->stringLike($event->getField(), "%" . $values['value'] . "%", $values['condition_pattern']));
         } else {
             $qb->andWhere($expr->stringLike($event->getField(), "%" . $values['value'] . "%"));
         }
     }
 }
Ejemplo n.º 2
0
 public function filterTextEntity(ApplyFilterEvent $event)
 {
     $qb = $event->getQueryBuilder();
     $values = $event->getValues();
     if (!empty($values['value'])) {
         $qb->select('a', 'c')->leftJoin($event->getField(), 'c')->where('c.id = :id')->setParameter('id', $values['value']->getId())->orderBy('a.id', 'DESC')->getQuery()->getResult();
     }
 }