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

api-platform / core / 6067528200

04 Sep 2023 12:12AM UTC coverage: 36.875% (-21.9%) from 58.794%
6067528200

Pull #5791

github

web-flow
Merge 64157e578 into d09cfc9d2
Pull Request #5791: fix: strip down any sql function name

3096 of 3096 new or added lines in 205 files covered. (100.0%)

9926 of 26918 relevant lines covered (36.87%)

6.5 hits per line

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

0.0
/src/Elasticsearch/Extension/AbstractFilterExtension.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\Elasticsearch\Extension;
15

16
use ApiPlatform\Metadata\Operation;
17
use Psr\Container\ContainerInterface;
18

19
/**
20
 * Abstract class for easing the implementation of a filter extension.
21
 *
22
 * @experimental
23
 *
24
 * @author Baptiste Meyer <baptiste.meyer@gmail.com>
25
 */
26
abstract class AbstractFilterExtension implements RequestBodySearchCollectionExtensionInterface
27
{
28
    public function __construct(private readonly ContainerInterface $filterLocator)
29
    {
30
    }
×
31

32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function applyToCollection(array $requestBody, string $resourceClass, Operation $operation = null, array $context = []): array
36
    {
37
        $resourceFilters = $operation?->getFilters();
×
38

39
        if (!$resourceFilters) {
×
40
            return $requestBody;
×
41
        }
42

43
        $context['filters'] ??= [];
×
44
        $clauseBody = [];
×
45

46
        foreach ($resourceFilters as $filterId) {
×
47
            if ($this->filterLocator->has($filterId) && is_a($filter = $this->filterLocator->get($filterId), $this->getFilterInterface())) {
×
48
                $clauseBody = $filter->apply($clauseBody, $resourceClass, $operation, $context);
×
49
            }
50
        }
51

52
        if (!$clauseBody) {
×
53
            return $requestBody;
×
54
        }
55

56
        return $this->alterRequestBody($requestBody, $clauseBody);
×
57
    }
58

59
    /**
60
     * Gets the related filter interface.
61
     */
62
    abstract protected function getFilterInterface(): string;
63

64
    /**
65
     * Alters the request body.
66
     */
67
    abstract protected function alterRequestBody(array $requestBody, array $clauseBody): array;
68
}
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