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

api-platform / core / 18343625207

08 Oct 2025 11:48AM UTC coverage: 24.542% (-0.02%) from 24.561%
18343625207

push

github

web-flow
fix(state): object mapper on delete operation (#7447)

fixes #7434

1 of 49 new or added lines in 2 files covered. (2.04%)

7084 existing lines in 207 files now uncovered.

14004 of 57061 relevant lines covered (24.54%)

26.01 hits per line

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

90.91
/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
    }
768✔
32

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

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

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

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

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

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

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

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

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

UNCOV
77
        return $resourceMetadataCollection;
112✔
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