Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
LinkRepository | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
search | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Olz\Repository\Service; |
4 | |
5 | use Doctrine\Common\Collections\Collection; |
6 | use Doctrine\Common\Collections\Criteria; |
7 | use Doctrine\Common\Collections\Order; |
8 | use Olz\Entity\Service\Link; |
9 | use Olz\Repository\Common\OlzRepository; |
10 | |
11 | /** |
12 | * @extends OlzRepository<Link> |
13 | */ |
14 | class LinkRepository extends OlzRepository { |
15 | /** |
16 | * @param string[] $terms |
17 | * |
18 | * @return Collection<int, Link>&iterable<Link> |
19 | */ |
20 | public function search(array $terms): Collection { |
21 | $criteria = Criteria::create() |
22 | ->where(Criteria::expr()->andX( |
23 | Criteria::expr()->eq('on_off', 1), |
24 | ...array_map(fn ($term) => Criteria::expr()->orX( |
25 | Criteria::expr()->contains('name', $term), |
26 | Criteria::expr()->contains('url', $term), |
27 | ), $terms), |
28 | )) |
29 | ->orderBy([ |
30 | 'position' => Order::Ascending, |
31 | ]) |
32 | ->setFirstResult(0) |
33 | ->setMaxResults(1000000) |
34 | ; |
35 | return $this->matching($criteria); |
36 | } |
37 | } |