Skip to content

[RFC] Dealing with plain PHP Api Resource #2683

@joelwurtz

Description

@joelwurtz

We got an app where we would expose a referential for our users through our API (using APIP)

We have something like this:

/**
 * @ApiResource
 */
abstract class FooReferential {
    abstract public function getId(): string;
    abstract public function getName(): string; 

   ...
}

final class FooReferentialItem1 extends FooReferential {
    ...
}

final class FooReferentialItem2 extends FooReferential {
    ...
}

Then we got a DataProvider where we inject all of this class and which allows to APIP to correctly get a collection.

Getting a collection works nicely, however other use cases does not work:

  • Getting a single item seems to work weirdly: adding an @id / @context on some properties
  • When having another Resource that use one of those item, class resolver get the final class (the item) and not the parent class which is the correct resource class. So this fails to correctly convert the item to an iri item.
  • Same as before when trying to post an entity with a reference to a referential item

I'm wondering if this is an use case that is supported or that you want to support: we want to expose a referential through an API where the data are in plain PHP (no Doctrine / Mongodb / ...)

IF that the case will do some PRS to try to support this is an better way in the future.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions