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

api-platform / core / 15023181448

14 May 2025 02:19PM UTC coverage: 0.0% (-8.4%) from 8.418%
15023181448

Pull #7139

github

web-flow
Merge 9f45709da into 1862d03b7
Pull Request #7139: refactor(symfony): remove obsolete option `validator.query-parameter-validation`

0 of 4 new or added lines in 1 file covered. (0.0%)

11266 existing lines in 366 files now uncovered.

0 of 50828 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/Metadata/Resource/Factory/FiltersResourceMetadataCollectionFactory.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\Metadata\Resource\Factory;
15

16
use ApiPlatform\Metadata\Exception\ResourceClassNotFoundException;
17
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
18
use ApiPlatform\Metadata\Util\AttributeFilterExtractorTrait;
19

20
/**
21
 * Creates a resource metadata from {@see Resource} annotations.
22
 *
23
 * @author Antoine Bluchet <soyuka@gmail.com>
24
 */
25
final class FiltersResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface
26
{
27
    use AttributeFilterExtractorTrait;
28

29
    public function __construct(private readonly ?ResourceMetadataCollectionFactoryInterface $decorated = null)
30
    {
UNCOV
31
    }
×
32

33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function create(string $resourceClass): ResourceMetadataCollection
37
    {
UNCOV
38
        $resourceMetadataCollection = new ResourceMetadataCollection($resourceClass);
×
39

UNCOV
40
        if ($this->decorated) {
×
UNCOV
41
            $resourceMetadataCollection = $this->decorated->create($resourceClass);
×
42
        }
43

44
        try {
UNCOV
45
            $reflectionClass = new \ReflectionClass($resourceClass);
×
46
        } catch (\ReflectionException) {
×
47
            throw new ResourceClassNotFoundException(\sprintf('Resource "%s" not found.', $resourceClass));
×
48
        }
49

UNCOV
50
        $classFilters = $this->readFilterAttributes($reflectionClass);
×
UNCOV
51
        $filters = [];
×
52

UNCOV
53
        foreach ($classFilters as $id => [$args, $filterClass, $attribute]) {
×
UNCOV
54
            if (!$attribute->alias) {
×
UNCOV
55
                $filters[] = $id;
×
56
            }
57
        }
58

UNCOV
59
        foreach ($resourceMetadataCollection as $i => $resource) {
×
UNCOV
60
            foreach ($operations = $resource->getOperations() ?? [] as $operationName => $operation) {
×
UNCOV
61
                $operations->add($operationName, $operation->withFilters(array_unique(array_merge($resource->getFilters() ?? [], $operation->getFilters() ?? [], $filters))));
×
62
            }
63

UNCOV
64
            if ($operations) {
×
UNCOV
65
                $resourceMetadataCollection[$i] = $resource->withOperations($operations);
×
66
            }
67

UNCOV
68
            foreach ($graphQlOperations = $resource->getGraphQlOperations() ?? [] as $operationName => $operation) {
×
UNCOV
69
                $graphQlOperations[$operationName] = $operation->withFilters(array_unique(array_merge($resource->getFilters() ?? [], $operation->getFilters() ?? [], $filters)));
×
70
            }
71

UNCOV
72
            if ($graphQlOperations) {
×
UNCOV
73
                $resourceMetadataCollection[$i] = $resource->withGraphQlOperations($graphQlOperations);
×
74
            }
75
        }
76

UNCOV
77
        return $resourceMetadataCollection;
×
78
    }
79
}
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

© 2025 Coveralls, Inc