Searcher.php 874B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Muzich\CoreBundle\Searcher;
  3. use Doctrine\ORM\Query;
  4. use Doctrine\Bundle\DoctrineBundle\Registry;
  5. /**
  6. * Objet utiliser pour cadrer la recherche.
  7. *
  8. */
  9. abstract class Searcher
  10. {
  11. /**
  12. * Query est l'objet requete correspondant a la recherche
  13. *
  14. * @var Query
  15. */
  16. protected $query = null;
  17. protected function setAttributes($params)
  18. {
  19. foreach ($params as $param_id => $param_value)
  20. {
  21. // TODO: check existance attribut
  22. if (property_exists($this, $param_id))
  23. {
  24. $this->$param_id = $param_value;
  25. }
  26. else
  27. {
  28. throw new \Exception("You're trying access unknow attribute '$param_id'");
  29. }
  30. }
  31. }
  32. protected function setQuery(Query $query)
  33. {
  34. $this->query = $query;
  35. }
  36. public function getQuery(Registry $doctrine, $user_id, $exec_type)
  37. {
  38. return $this->query;
  39. }
  40. }