|
- <?php
-
- namespace Lc\PietroBundle\Repository\Search;
-
-
- use Lc\PietroBundle\Model\Thematic;
- use Doctrine\Common\Collections\ArrayCollection;
- use Lc\SovBundle\Repository\AbstractStore;
- use Lc\SovBundle\Repository\RepositoryQueryInterface;
- use Lc\SovBundle\Repository\StoreInterface;
-
- class SearchStore extends AbstractStore implements StoreInterface
- {
-
- public function __construct($query)
- {
- $this->query = $query;
- }
-
- public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->orderBy('id');
- return $query;
- }
-
- public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- $query->filterIsValid();
- return $query;
- }
-
- public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
- {
- return $query;
- }
-
- public function filterSearch(
- ?string $subthematic,
- ArrayCollection $territoryArray,
- ArrayCollection $thematicArray,
- $query = null
- ) {
- $query = $this->createDefaultQuery($query);
-
- if (!($thematicArray->isEmpty())) {
- $query->filterByThematic($thematicArray);
- }
- if (!($territoryArray->isEmpty())) {
- $query->filterByTerritory($territoryArray);
- }
- if (!empty($subthematic)) {
- $query->filterBySubthematicName($subthematic);
- }
-
- return $query->find();
- }
-
- public function getByThematic(Thematic $thematic, $query = null)
- {
- $query = $this->createDefaultQuery($query);
- $query->filterByThematic(new ArrayCollection([$thematic]));
-
- return $query->find();
- }
-
- }
|