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

api-platform / core / 19799301771

30 Nov 2025 01:04PM UTC coverage: 25.229% (-0.03%) from 25.257%
19799301771

push

github

web-flow
fix(metadata): repeatable attribute mutators (#7542)

14557 of 57700 relevant lines covered (25.23%)

28.11 hits per line

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

100.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
    }
2✔
38

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

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

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

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

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

70
        $queryBuilder->setParameters($parameters);
8✔
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