[wp-trac] [WordPress Trac] #41111: WP-API JS Client: Add a helper to get model or collection by route

WordPress Trac noreply at wordpress.org
Wed Jun 21 09:51:03 UTC 2017


#41111: WP-API JS Client: Add a helper to get model or collection by route
-------------------------+-------------------------------------------------
 Reporter:               |      Owner:
  adamsilverstein        |     Status:  new
     Type:  enhancement  |  Milestone:  4.9
 Priority:  normal       |    Version:  4.7
Component:  REST API     |   Keywords:  good-first-bug needs-patch needs-
 Severity:  normal       |  unit-tests
  Focuses:  javascript   |
-------------------------+-------------------------------------------------
 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 [https://github.com/WordPress/gutenberg/pull/1276 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.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41111>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list