Skip to content

Doctrine: stateOptions IRI now can't be generated with default entity providers #5733

Description

@weaverryan

API Platform version(s) affected: 3.1-dev (unreleased)

Description
@soyuka is helping me out BIG time to get stateOptions: new Options(entityClass: User::class), working nicely. #5726 fixed a bug where IRI generation would fail if you implemented a custom provider that returned your DTO objects. That seems to work great!

However, now the default case looks broken in the same way. Consider:

#[ApiResource(
stateOptions: newOptions(entityClass: User::class),
)]
class UserApi

This will now fail with Unable to generate an IRI for the item of type "App\ApiResource\UserApi. It's the opposite problem as before: IdentifiersExtractor will not grab the id because here -

if ($iteminstanceof$class) {
- $item will be the entity (User) but $class will be UserApi.

How to reproduce

I have an easy reproducer here: https://github.com/symfonycasts/api-platform3/tree/playing-with-stateOptions

You can see it working, at first, with a custom provider that returns the DTOs. Then, by commenting-out the provider option, you can see it fail when the core provider returns the entity objects.

Thanks for your attention - this is all nearly working perfectly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions