Opened 5 weeks ago
Last modified 4 weeks ago
#41111 assigned enhancement
WP-API JS Client: Add a helper to get model or collection by route
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.9 | Priority: | normal |
| Severity: | normal | Version: | 4.7 |
| Component: | REST API | Keywords: | good-first-bug needs-patch needs-unit-tests |
| Focuses: | javascript | Cc: |
Description
In the process of adding page/custom post type support to Gutenberg, the need arose to identify the models based on their route - the code passes the route from PHP to JavaScript, and the JavaScript needs to know which model to use. See this pull requst for additional details.
We should add helpers to the client to easily find a model or collection based on its route, something like getModelByRoute and getCollectionByRoute - each would search thru the constructed models/collections and return the matching object, or false if none was found. We should also add unit tests to verify the functions work as expected.
Change History (2)
#1
@adamsilverstein
5 weeks ago
- Owner set to adamsilverstein
- Status changed from new to assigned