Nayte
Nayte

Reputation: 69

API-Platform : expose an entity only as a subresource

The question is about a PHP 8.0 / symfony 5.3 / API-Platform 2.6 project.

What I try to achieve is to restrict Game to ONLY be exposed as a User's subresource , like this:

https://whatever.com/users/{id}/games/{id}

And NOT have the generic endpoint anymore, for games, like this:

https://whatever.com/games/{id}

Do you know how to perform this restriction?

Upvotes: 0

Views: 992

Answers (1)

Kévin Dunglas
Kévin Dunglas

Reputation: 3024

This is only possible with API Platform version 2.7+, which is currently in development (but usable, install the main branch). In this version "subresources” are gone, but new PHP attributes have been introduced allowing to use arbitrary URLs. This basically replace subresources and add write support (POST, PUT, PATCH, DELETE) to them.

Upvotes: 1

Related Questions