SearchController.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Muzich\CoreBundle\Controller;
  3. use Muzich\CoreBundle\lib\Controller;
  4. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  5. use Muzich\CoreBundle\Searcher\ElementSearcher;
  6. use Muzich\CoreBundle\Form\Search\ElementSearchForm;
  7. use Doctrine\ORM\Query;
  8. class SearchController extends Controller
  9. {
  10. /**
  11. * Procédure de recherche, qui met a jour l'objet de recherche (ainsi
  12. * que les paramétres en session).
  13. *
  14. */
  15. public function searchElementsAction()
  16. {
  17. $request = $this->getRequest();
  18. $search_object = $this->getElementSearcher($this->getUser()->getId());
  19. $search_form = $this->createForm(
  20. new ElementSearchForm(),
  21. $search_object->getParams(),
  22. array('tags' => $this->getTagsArray())
  23. );
  24. if ($request->getMethod() == 'POST')
  25. {
  26. $search_form->bindRequest($request);
  27. if ($search_form->isValid())
  28. {
  29. $search_object->update($search_form->getData());
  30. $this->setElementSearcher($search_object);
  31. }
  32. }
  33. if ($this->getRequest()->isXmlHttpRequest())
  34. {
  35. // template qui apelle doSearchElementsAction
  36. }
  37. else
  38. {
  39. return $this->redirect($this->generateUrl('home'));
  40. }
  41. }
  42. }