Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| TerminRepository | |
0.00% |
0 / 30 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| getAllActive | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| search | |
0.00% |
0 / 20 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Olz\Repository\Termine; |
| 4 | |
| 5 | use Doctrine\Common\Collections\Collection; |
| 6 | use Doctrine\Common\Collections\Criteria; |
| 7 | use Doctrine\Common\Collections\Order; |
| 8 | use Olz\Entity\Termine\Termin; |
| 9 | use Olz\Repository\Common\OlzRepository; |
| 10 | |
| 11 | /** |
| 12 | * @extends OlzRepository<Termin> |
| 13 | */ |
| 14 | class TerminRepository extends OlzRepository { |
| 15 | /** @return Collection<int, Termin>&iterable<Termin> */ |
| 16 | public function getAllActive(): Collection { |
| 17 | $is_not_archived = $this->termineUtils()->getIsNotArchivedCriteria(); |
| 18 | $criteria = Criteria::create() |
| 19 | ->where(Criteria::expr()->andX( |
| 20 | $is_not_archived, |
| 21 | Criteria::expr()->eq('on_off', 1), |
| 22 | )) |
| 23 | ->setFirstResult(0) |
| 24 | ->setMaxResults(1000000) |
| 25 | ; |
| 26 | return $this->matching($criteria); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * @param string[] $terms |
| 31 | * |
| 32 | * @return Collection<int, Termin>&iterable<Termin> |
| 33 | */ |
| 34 | public function search(array $terms): Collection { |
| 35 | $is_not_archived = $this->termineUtils()->getIsNotArchivedCriteria(); |
| 36 | // $qb = $this->createQueryBuilder('t'); |
| 37 | // $qb->join('t.location', 'l') |
| 38 | // ->where( |
| 39 | // $qb->expr()->andX( |
| 40 | // $is_not_archived, |
| 41 | // $qb->expr()->eq('t.on_off', 1), |
| 42 | // ...array_map(fn ($term) => $qb->expr()->orX( |
| 43 | // $qb->expr()->like('t.title', "%{$term}%"), |
| 44 | // $qb->expr()->like('t.text', "%{$term}%"), |
| 45 | // $qb->expr()->like('l.name', "%{$term}%"), |
| 46 | // $qb->expr()->like('l.details', "%{$term}%"), |
| 47 | // ...$this->searchUtils()->getDateCriteria('t.start_date', $term), |
| 48 | // ...$this->searchUtils()->getDateCriteria('t.end_date', $term), |
| 49 | // ), $terms), |
| 50 | // ) |
| 51 | // ) |
| 52 | // ->orderBy('t.start_date', 'ASC') |
| 53 | // ->addOrderBy('t.start_time', 'ASC') |
| 54 | // ->setFirstResult(0) |
| 55 | // ->setMaxResults(1000000); |
| 56 | |
| 57 | // return $qb->getQuery()->getResult(); |
| 58 | |
| 59 | $criteria = Criteria::create() |
| 60 | ->where(Criteria::expr()->andX( |
| 61 | $is_not_archived, |
| 62 | Criteria::expr()->eq('on_off', 1), |
| 63 | ...array_map(fn ($term) => Criteria::expr()->orX( |
| 64 | Criteria::expr()->contains('title', $term), |
| 65 | Criteria::expr()->contains('text', $term), |
| 66 | ...$this->searchUtils()->getDateCriteria('start_date', $term), |
| 67 | ...$this->searchUtils()->getDateCriteria('end_date', $term), |
| 68 | ), $terms), |
| 69 | )) |
| 70 | ->orderBy([ |
| 71 | 'start_date' => Order::Ascending, |
| 72 | 'start_time' => Order::Ascending, |
| 73 | ]) |
| 74 | ->setFirstResult(0) |
| 75 | ->setMaxResults(1000000) |
| 76 | ; |
| 77 | return $this->matching($criteria); |
| 78 | } |
| 79 | } |