api-platform / docs

API Platform documentation
https://api-platform.com/docs/
164 stars 1.05k forks source link

fix: add missing import to identifiers #1946

Closed mboultoureau closed 2 months ago

mboultoureau commented 2 months ago

Add missing import in identifiers.md.

<?php
// api/src/State/PersonProvider.php

namespace App\State;

use App\Entity\Person;
+ use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;
use App\Uuid;

/**
 * @implements ProviderInterface<Person>
 */
final class PersonProvider implements ProviderInterface
{
    public function provide(Operation $operation, array $uriVariables = [], array $context = []): Person
    {
        // Our identifier is:
        // $uriVariables['code']
        // although it's a string, it's not an instance of Uuid and we wanted to retrieve the timestamp of our time-based uuid:
        // $uriVariable['code']->getTimestamp()
    }
}