UserAndGroupSearcher.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Muzich\CoreBundle\Searcher;
  3. use Symfony\Component\Validator\Constraints as Assert;
  4. class UserAndGroupSearcher extends Searcher implements SearcherInterface
  5. {
  6. /**
  7. * Chaine de caractère représentant la recherche.
  8. *
  9. * @var string
  10. * @Assert\NotBlank()
  11. * @Assert\Type("string")
  12. * @Assert\MinLength(3)
  13. */
  14. protected $string;
  15. /**
  16. * @see SearcherInterface
  17. * @param array $params
  18. */
  19. public function init($params)
  20. {
  21. // Control des parametres transmis.
  22. $this->checkParams($params, array(
  23. 'string' => "Muzich\CoreBundle\Searcher\UserAndGroupSearch::init(): \$params: Un string est nécéssaire"
  24. ));
  25. // Mise a jour des attributs
  26. $this->setAttributes(array('string', 'min_lenght'), $params);
  27. }
  28. /**
  29. * @see SearcherInterface
  30. * @param array $params
  31. */
  32. public function update($params)
  33. {
  34. // Mise a jour des attributs
  35. $this->setAttributes(array(
  36. 'string', 'min_length'
  37. ), $params);
  38. }
  39. /**
  40. * @see SearcherInterface
  41. *
  42. * @return array
  43. */
  44. public function getParams()
  45. {
  46. return array(
  47. 'string' => $this->string,
  48. 'min_length' => $this->min_length
  49. );
  50. }
  51. public function getString()
  52. {
  53. return $this->string;
  54. }
  55. public function setString($string)
  56. {
  57. $this->string = $string;
  58. }
  59. }