Exemple #1
0
 /**
  * Handle stock search AJAX request
  *
  * @Route("/stocks/search")
  *
  * @param  Symfony\Component\HttpFoundation\Request  $request
  * @return Symfony\Component\HttpFoundation\Response
  */
 public function stockSearchAction(Request $request)
 {
     $searchQuery = new SearchQuery();
     $searchQuery->setSecurityContext($this->getSecurityContext());
     $searchQuery->setTerms($request->query->get('query'));
     $query = $this->getObjectManager()->getRepository('VIBFliesBundle:Stock')->getSearchQuery($searchQuery);
     $found = $query->getResult();
     $stockNames = array();
     foreach ($found as $stock) {
         $stockNames[] = $stock->getName();
     }
     $response = new JsonResponse();
     $response->setData(array('options' => $stockNames));
     return $response;
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 protected function createSearchQuery($advanced = false)
 {
     $searchQuery = new SearchQuery($advanced);
     $searchQuery->setSecurityContext($this->getSecurityContext());
     return $searchQuery;
 }