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

api-platform / core / 19189991188

08 Nov 2025 07:33AM UTC coverage: 0.0%. First build
19189991188

Pull #7516

github

web-flow
Merge c6e814fbd into a7e524051
Pull Request #7516: feat(metadata): cache operation metadata factory

0 of 29 new or added lines in 3 files covered. (0.0%)

0 of 56790 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/Operation/Factory/OperationMetadataFactory.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\Operation\Factory;
15

16
use ApiPlatform\Metadata\Operation;
17
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
18
use ApiPlatform\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
19

20
final class OperationMetadataFactory implements OperationMetadataFactoryInterface
21
{
22
    private array $localCache = [];
23

24
    public function __construct(private readonly ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory)
25
    {
26
    }
×
27

28
    public function create(string $uriTemplate, array $context = []): ?Operation
29
    {
NEW
30
        if (isset($this->localCache[$uriTemplate])) {
×
NEW
31
            return $this->localCache[$uriTemplate];
×
32
        }
33

34
        foreach ($this->resourceNameCollectionFactory->create() as $resourceClass) {
×
35
            foreach ($this->resourceMetadataCollectionFactory->create($resourceClass) as $resource) {
×
36
                foreach ($resource->getOperations() as $operation) {
×
37
                    if ($operation->getUriTemplate() === $uriTemplate || $operation->getName() === $uriTemplate) {
×
NEW
38
                        return $this->localCache[$uriTemplate] = $operation;
×
39
                    }
40
                }
41
            }
42
        }
43

44
        return null;
×
45
    }
46
}
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