MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //home/cafsindia/lead_cafsinfotech.com/vendor/api-platform/core/src/Action/EntrypointAction.php
<?php

/*
 * This file is part of the API Platform project.
 *
 * (c) Kévin Dunglas <dunglas@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

declare(strict_types=1);

namespace ApiPlatform\Action;

use ApiPlatform\Api\Entrypoint;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
use ApiPlatform\State\ProcessorInterface;
use ApiPlatform\State\ProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * Generates the API entrypoint.
 *
 * @deprecated use ApiPlatform\Documentation\Action\EntrypointAction
 *
 * @author Kévin Dunglas <dunglas@gmail.com>
 */
final class EntrypointAction
{
    public function __construct(
        private readonly ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory,
        private readonly ?ProviderInterface $provider = null,
        private readonly ?ProcessorInterface $processor = null,
        private readonly array $documentationFormats = []
    ) {
    }

    /**
     * @return Entrypoint|Response
     */
    public function __invoke(?Request $request = null)
    {
        if ($this->provider && $this->processor) {
            $context = ['request' => $request];
            $operation = new Get(outputFormats: $this->documentationFormats, read: true, serialize: true, class: Entrypoint::class, provider: fn () => new Entrypoint($this->resourceNameCollectionFactory->create()));
            $body = $this->provider->provide($operation, [], $context);
            // see https://github.com/api-platform/core/issues/5845#issuecomment-1732400657
            if ($request && ($apiOperation = $request->attributes->get('_api_operation'))) {
                $operation = $apiOperation;
            }

            return $this->processor->process($body, $operation, [], $context);
        }

        return new Entrypoint($this->resourceNameCollectionFactory->create());
    }
}