• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 19337721455

13 Nov 2025 04:02PM UTC coverage: 0.0% (-24.6%) from 24.631%
19337721455

push

github

soyuka
Merge 4.1

0 of 56854 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Doctrine/Orm/Filter/FreeTextQueryFilter.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Doctrine\Orm\Filter;
15

16
use ApiPlatform\Doctrine\Common\Filter\LoggerAwareInterface;
17
use ApiPlatform\Doctrine\Common\Filter\LoggerAwareTrait;
18
use ApiPlatform\Doctrine\Common\Filter\ManagerRegistryAwareInterface;
19
use ApiPlatform\Doctrine\Common\Filter\ManagerRegistryAwareTrait;
20
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
21
use ApiPlatform\Metadata\BackwardCompatibleFilterDescriptionTrait;
22
use ApiPlatform\Metadata\Operation;
23
use Doctrine\Common\Collections\ArrayCollection;
24
use Doctrine\ORM\QueryBuilder;
25

26
final class FreeTextQueryFilter implements FilterInterface, ManagerRegistryAwareInterface, LoggerAwareInterface
27
{
28
    use BackwardCompatibleFilterDescriptionTrait;
29
    use LoggerAwareTrait;
30
    use ManagerRegistryAwareTrait;
31

32
    /**
33
     * @param list<string> $properties an array of properties, defaults to `parameter->getProperties()`
34
     */
35
    public function __construct(private readonly FilterInterface $filter, private readonly ?array $properties = null)
36
    {
37
    }
×
38

39
    public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
40
    {
41
        if ($this->filter instanceof ManagerRegistryAwareInterface) {
×
42
            $this->filter->setManagerRegistry($this->getManagerRegistry());
×
43
        }
44

45
        if ($this->filter instanceof LoggerAwareInterface) {
×
46
            $this->filter->setLogger($this->getLogger());
×
47
        }
48

49
        $parameter = $context['parameter'];
×
50
        $qb = clone $queryBuilder;
×
51
        $qb->resetDQLPart('where');
×
52
        $qb->setParameters(new ArrayCollection());
×
53
        foreach ($this->properties ?? $parameter->getProperties() ?? [] as $property) {
×
54
            $this->filter->apply(
×
55
                $qb,
×
56
                $queryNameGenerator,
×
57
                $resourceClass,
×
58
                $operation,
×
59
                ['parameter' => $parameter->withProperty($property)] + $context
×
60
            );
×
61
        }
62

63
        $queryBuilder->andWhere($qb->getDQLPart('where'));
×
64
        $parameters = $queryBuilder->getParameters();
×
65

66
        foreach ($qb->getParameters() as $p) {
×
67
            $parameters->add($p);
×
68
        }
69

70
        $queryBuilder->setParameters($parameters);
×
71
    }
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc