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

api-platform / core / 16050929464

03 Jul 2025 12:51PM UTC coverage: 22.065% (+0.2%) from 21.821%
16050929464

push

github

soyuka
chore: todo improvement

11516 of 52192 relevant lines covered (22.06%)

22.08 hits per line

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

100.0
/src/Symfony/Action/EntrypointAction.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\Symfony\Action;
15

16
use ApiPlatform\Documentation\Entrypoint;
17
use ApiPlatform\Metadata\Get;
18
use ApiPlatform\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
19
use ApiPlatform\Metadata\Resource\ResourceNameCollection;
20
use ApiPlatform\OpenApi\Serializer\LegacyOpenApiNormalizer;
21
use ApiPlatform\State\ProcessorInterface;
22
use ApiPlatform\State\ProviderInterface;
23
use Symfony\Component\HttpFoundation\Request;
24

25
/**
26
 * Generates the API entrypoint.
27
 *
28
 * @author Kévin Dunglas <dunglas@gmail.com>
29
 */
30
final class EntrypointAction
31
{
32
    private static ResourceNameCollection $resourceNameCollection;
33

34
    public function __construct(
35
        private readonly ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory,
36
        private readonly ProviderInterface $provider,
37
        private readonly ProcessorInterface $processor,
38
        private readonly array $documentationFormats = [],
39
    ) {
40
    }
16✔
41

42
    public function __invoke(Request $request): mixed
43
    {
44
        static::$resourceNameCollection = $this->resourceNameCollectionFactory->create();
16✔
45
        $context = [
16✔
46
            'request' => $request,
16✔
47
            'spec_version' => (string) $request->query->get(LegacyOpenApiNormalizer::SPEC_VERSION),
16✔
48
        ];
16✔
49
        $request->attributes->set('_api_platform_disable_listeners', true);
16✔
50
        $operation = new Get(
16✔
51
            outputFormats: $this->documentationFormats,
16✔
52
            read: true,
16✔
53
            serialize: true,
16✔
54
            class: Entrypoint::class,
16✔
55
            provider: [self::class, 'provide']
16✔
56
        );
16✔
57
        $request->attributes->set('_api_operation', $operation);
16✔
58
        $body = $this->provider->provide($operation, [], $context);
16✔
59
        $operation = $request->attributes->get('_api_operation');
16✔
60

61
        return $this->processor->process($body, $operation, [], $context);
16✔
62
    }
63

64
    public static function provide(): Entrypoint
65
    {
66
        return new Entrypoint(static::$resourceNameCollection);
12✔
67
    }
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