Repository navigation
Conversation
Alternative to api-platform#8813 for api-platform#8791: keep a real class, carry one ApiResource per dynamic model and pick it through ResourceAwareInterface; property factories receive the object's operation_name next to root_operation_name.
|
Keeping a real class does avoid all the My concern is that with a shared class,
Some of these are inferred from reading the code and haven't been tested. The cheapest checks would be Fixing this approach means passing the operation or object through to each of these sites, or adding a For comparison, #8813 has the opposite trade-off:
I think the two could be combined. Keep the resource name as
That would cover both columns without relying on |
Alternative to #8813, same functional test (plus a second model and a nested case). Instead of putting a name that is not a class in
Operation::classand guarding every reflection /getManagerForClass()call, we keep a real class (DynamicRecord) and declare oneApiResourceper dynamic model on it, distinguished byshortName. SeveralApiResourceon one class is already supported, so metadata, routes,getResourceFromIri()and Doctrine factories work untouched, noclass_existsneeded.Two things were missing:
operation_namein the factory options is now the operation of the object/schema being built (it was set but never read),root_operation_namestays the source of the groups.SchemaFactorypasses it too.ApiResourcefrom an object on a shared class:ResourceAwareInterface::getResource()(the shortName) +ResourceMetadataCollection::getOperationForObject(), used byAbstractItemNormalizer, the JSON-LDItemNormalizerand the SymfonyIriConverter.Not covered yet: nested JSON Schema (
ResourceMetadataTrait::findOperationtakes the first resource), LaravelIriConverter, JSON:APIgetRelationship, denormalization / instantiation. The property cache also gets one entry per operation for root items now, to be measured.