找不到自定义 API 平台数据提供程序

Custom API Platform data provider not being found

我已经创建了一个自定义数据提供者和相应的实体。我现在添加了虚拟数据,因为它不起作用。该资源在文档中可用并且操作运行,但端点返回时总是没有数据。我的实体在这里

<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;

/**
 * @ApiResource(
 *     collectionOperations={"get"},
 *     itemOperations={"get"}
 * )
 */
class Region
{
    /**
     * @ApiProperty(identifier=true)
     */
    private $id;

    private $name;

    public function __construct(int $id, string $name)
    {
        $this->id = $id;
        $this->name = $name;
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }
}

数据提供者是

<?php

namespace App\DataProvider;

use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
use App\Entity\Region;
use Doctrine\ORM\EntityManagerInterface;

class RegionDataProvider implements CollectionDataProviderInterface, 
RestrictedDataProviderInterface
{
    /**
     * @param string      $resourceClass
     * @param string|null $operationName
     *
     * @return \Traversable
     */
    public function getCollection(string $resourceClass, string $operationName = null): 
    \Traversable
    {
        yield new Region(1, 'Region 1');
        yield new Region(2, 'Region 2');
        yield new Region(3, 'Region 3');
        yield new Region(4, 'Region 4');
    }

    /**
     * @param string      $resourceClass
     * @param string|null $operationName
     * @param array       $context
     *
     * @return bool
     */
    public function supports(string $resourceClass, string $operationName = null, array 
    $context = []): bool
    {
        return (Region::class === $resourceClass) && ('GET' === $operationName);
    }
}

我已经尝试了各种使用数据提供程序服务的方法,自动连接或显式配置。端点有效但从未 returns 任何数据

只是改变

('GET' === $operationName)

('get' === $operationName)