You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3KB

  1. <?php
  2. namespace App\Repository;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Lc\SovBundle\Repository\AbstractStore;
  5. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  6. use Lc\SovBundle\Repository\StoreInterface;
  7. class SearchStore extends AbstractStore implements StoreInterface
  8. {
  9. public function __construct($query)
  10. {
  11. $this->query = $query;
  12. }
  13. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  14. {
  15. $query->orderBy('id');
  16. return $query;
  17. }
  18. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  19. {
  20. $query->filterIsValid();
  21. return $query;
  22. }
  23. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  24. {
  25. return $query;
  26. }
  27. public function filterSearch(
  28. ?string $description,
  29. ArrayCollection $territoryArray,
  30. ArrayCollection $thematicArray,
  31. $query = null
  32. ) {
  33. $query = $this->createDefaultQuery($query);
  34. $query
  35. ->filterByThematic($thematicArray)
  36. ->filterByTerritory($territoryArray);
  37. if (!empty($description)) {
  38. $query->filterByDescription($description);
  39. }
  40. return $query->find();
  41. }
  42. }