/**
  * 
  * @param Search $search
  * @return array|null
  */
 public function search($search)
 {
     if (!$search instanceof Search) {
         $s = new Search();
         $s->setQuery($search);
         $keywords = $s->getKeywords();
     }
     if (empty($keywords)) {
         return array();
     }
     $qb = $this->getSearchQb();
     if ($qb === null) {
         return null;
     }
     $params = $this->getSearchParams();
     $wheres = array();
     foreach ($keywords as $key => $keyword) {
         foreach ($params as $param) {
             $wheres[$param][] = $param . ' LIKE ?' . $key;
         }
         $qb->setParameter($key, '%' . $keyword . '%');
         //$qb->orWhere($param . ' LIKE ?'.$key);
     }
     foreach ($params as $param) {
         $qb->orWhere(implode(' OR ', $wheres[$param]));
     }
     $orderBys = $this->getSearchOrderBy();
     foreach ($orderBys as $champ => $order) {
         /* VĂ©rifier $order = 'asc' ou 'desc' */
         $qb->addOrderBy($champ, $order);
     }
     return $qb->getQuery()->getResult();
 }
 /**
  * @Route("/search",name="transmitter_search")
  * @Method("get")
  * @Template()
  */
 public function searchAction(Request $request)
 {
     $formData = $request->get('jlm_core_search');
     if (is_array($formData) && array_key_exists('query', $formData)) {
         $em = $this->getDoctrine()->getManager();
         $entity = new Search();
         $query = $formData['query'];
         $entity->setQuery($query);
         return array('transmitters' => $em->getRepository('JLMTransmitterBundle:Transmitter')->search($entity), 'asks' => $em->getRepository('JLMTransmitterBundle:Ask')->search($entity));
     }
     return array();
 }