/** * método para pesquisa de unidades organizacinais para combo * @param array $params * @return array $out */ public function sistemaAutoComplete(\Core_Dto_Search $dto, $entidade) { $queryBuilder = $this->_em->createQueryBuilder(); $query = $queryBuilder->select('c')->from($entidade, 'c'); if (!is_null($dto->hasQuery())) { $search = mb_strtolower($dto->getQuery(), 'UTF-8'); $field = $queryBuilder->expr()->lower($queryBuilder->expr()->trim('c.nome')); $query->andWhere($queryBuilder->expr()->like('clear_accentuation(' . $field . ')', $queryBuilder->expr()->literal($this->removeAccent('%' . $search . '%')))); } $query->setMaxResults(10); $res = $query->getQuery()->getArrayResult(); $out = array(); foreach ($res as $item) { $out[$item['codigo']] = $item['nome']; } return $out; }