Allow an arbitrary number of entity properties to route placeholders mappings in metadatamaps
corentin-larose opened this issue · comments
Feature Request
Q | A |
---|---|
New Feature | yes |
RFC | yes |
BC Break | no |
Summary
Let's say I have an applicant table, a skill table and a N:M relationship table to list applicant's skills.
Let's say I have a REST API with these routes:
Read applicants collection: /api/rest/v1/applicants^GET
Read applicant entity: /api/rest/v1/applicants/{id}^GET
Read skills collection: /api/rest/v1/skills^GET
Read skill entity: /api/rest/v1/skills/{id}^GET
Read an applicant's skills collection: /api/rest/v1/applicants/{applicant_id}/skills^GET
Read an applicant's skill entity: /api/rest/v1/applicants/{id0}/skills/{id1}^GET
For this last case, in my metadatamap, I can't use resource_identifier
, route_identifier_placeholder
options twice to map my entity properties to the route palceholder.
I propose o add the possibility of mapping an arbitrary number of entity properties to palceholders.
Settings would look like this in MetadataMap:
[
'identifiers_to_placeholders_mapping' => [
'applicant_id' => 'id0',
'skill_id' => 'id1',
],
'__class__' => RouteBasedResourceMetadata::class,
'extractor' => ObjectPropertyHydrator::class,
'resource_class' => ApplicantSkillEntity::class,
'route' => '/api/rest/v1/applicants/{id0}/skills/{id1}^GET',
],
If the principle is accepted, I will add the unit tests and documentation to my commit.
Fixed with #13