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

api-platform / core / 16053734897

03 Jul 2025 02:52PM UTC coverage: 22.132% (-0.4%) from 22.566%
16053734897

Pull #7274

github

web-flow
Merge 459b4021a into 828b62a4e
Pull Request #7274: fix(symfony): restore graphql_playground option

3 of 3 new or added lines in 1 file covered. (100.0%)

3831 existing lines in 106 files now uncovered.

11560 of 52232 relevant lines covered (22.13%)

23.34 hits per line

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

0.0
/src/Doctrine/Odm/Metadata/Resource/DoctrineMongoDbOdmResourceCollectionMetadataFactory.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\Odm\Metadata\Resource;
15

16
use ApiPlatform\Doctrine\Odm\State\CollectionProvider;
17
use ApiPlatform\Doctrine\Odm\State\ItemProvider;
18
use ApiPlatform\Doctrine\Odm\State\Options;
19
use ApiPlatform\Metadata\CollectionOperationInterface;
20
use ApiPlatform\Metadata\DeleteOperationInterface;
21
use ApiPlatform\Metadata\Operation;
22
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
23
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
24
use ApiPlatform\State\Util\StateOptionsTrait;
25
use Doctrine\ODM\MongoDB\DocumentManager;
26
use Doctrine\Persistence\ManagerRegistry;
27

28
final class DoctrineMongoDbOdmResourceCollectionMetadataFactory implements ResourceMetadataCollectionFactoryInterface
29
{
30
    use StateOptionsTrait;
31

32
    public function __construct(private readonly ManagerRegistry $managerRegistry, private readonly ResourceMetadataCollectionFactoryInterface $decorated)
33
    {
UNCOV
34
    }
×
35

36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function create(string $resourceClass): ResourceMetadataCollection
40
    {
UNCOV
41
        $resourceMetadataCollection = $this->decorated->create($resourceClass);
×
42

UNCOV
43
        foreach ($resourceMetadataCollection as $i => $resourceMetadata) {
×
UNCOV
44
            $operations = $resourceMetadata->getOperations();
×
45

46
            if ($operations) {
×
UNCOV
47
                foreach ($resourceMetadata->getOperations() as $operationName => $operation) {
×
48
                    $documentClass = $this->getStateOptionsClass($operation, $operation->getClass(), Options::class);
×
UNCOV
49
                    if (!$this->managerRegistry->getManagerForClass($documentClass) instanceof DocumentManager) {
×
50
                        continue;
×
51
                    }
52

53
                    $operations->add($operationName, $this->addDefaults($operation));
×
54
                }
55

56
                $resourceMetadata = $resourceMetadata->withOperations($operations);
×
57
            }
58

59
            $graphQlOperations = $resourceMetadata->getGraphQlOperations();
×
60

UNCOV
61
            if ($graphQlOperations) {
×
62
                foreach ($graphQlOperations as $operationName => $graphQlOperation) {
×
UNCOV
63
                    if (!$this->managerRegistry->getManagerForClass($graphQlOperation->getClass()) instanceof DocumentManager) {
×
64
                        continue;
×
65
                    }
66

67
                    $graphQlOperations[$operationName] = $this->addDefaults($graphQlOperation);
×
68
                }
69

70
                $resourceMetadata = $resourceMetadata->withGraphQlOperations($graphQlOperations);
×
71
            }
72

73
            $resourceMetadataCollection[$i] = $resourceMetadata;
×
74
        }
75

76
        return $resourceMetadataCollection;
×
77
    }
78

79
    private function addDefaults(Operation $operation): Operation
80
    {
UNCOV
81
        $options = $operation->getStateOptions() ?: new Options();
×
UNCOV
82
        if ($options instanceof Options && null === $options->getHandleLinks()) {
×
UNCOV
83
            $options = $options->withHandleLinks('api_platform.doctrine.odm.links_handler');
×
84
            $operation = $operation->withStateOptions($options);
×
85
        }
86

87
        if (null === $operation->getProvider()) {
×
UNCOV
88
            $operation = $operation->withProvider($this->getProvider($operation));
×
89
        }
90

91
        if (null === $operation->getProcessor()) {
×
UNCOV
92
            $operation = $operation->withProcessor($this->getProcessor($operation));
×
93
        }
94

95
        return $operation;
×
96
    }
97

98
    private function getProvider(Operation $operation): string
99
    {
UNCOV
100
        if ($operation instanceof CollectionOperationInterface) {
×
UNCOV
101
            return CollectionProvider::class;
×
102
        }
103

104
        return ItemProvider::class;
×
105
    }
106

107
    private function getProcessor(Operation $operation): string
108
    {
UNCOV
109
        if ($operation instanceof DeleteOperationInterface) {
×
UNCOV
110
            return 'api_platform.doctrine_mongodb.odm.state.remove_processor';
×
111
        }
112

113
        return 'api_platform.doctrine_mongodb.odm.state.persist_processor';
×
114
    }
115
}
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