I like to generate the uri for an APiPlatform resource, which seems pretty elementary to me, but I can't seem to find out how. This is what I'd like to accomplish:
Given the resource definition below I'd like get the url based on the resource class name, operation type and operation name.
/**
* @ApiResource(
* itemOperations={"GET"},
* collectionOperations={"GET"}
* )
*/
class Customer
{
// ...
}
$path = $someApiPlatformService->getOperationPath(Customer::class, ApiPlatform\Core\Api\OperationType::COLLECTION, 'GET');
Expected value of path would be /api/customers.
$itemId = 'someid';
$path = $someApiPlatformService->getOperationPath(Customer::class, ApiPlatform\Core\Api\OperationType::ITEM, 'GET', $itemId);
Expected value of path would be /api/customers/someid.