[wp-trac] [WordPress Trac] #42737: Add method wp.api.getModelByType for retrieving api models

WordPress Trac noreply at wordpress.org
Tue Nov 28 17:52:56 UTC 2017


#42737: Add method wp.api.getModelByType for retrieving api models
-----------------------------+-----------------------------
 Reporter:  mkaz             |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  REST API         |    Version:  trunk
 Severity:  normal           |   Keywords:
  Focuses:  javascript       |
-----------------------------+-----------------------------
 For Gutenberg, it will be easier and less error prone to fetch the
 wp.api.model by retrieving by type instead of creating a route and
 searching for the model that matches that route.

 An open detail to work out is if namespacing is needed, can objects have
 the same name in different API namespaces in the same instance of wp.api.
 A potential solution could be an optional second argument.

 For example: `getModelByType( type, versionString = 'wp/v2' )`


 Related to #41111

 Original Slack Discussion at:
 https://wordpress.slack.com/archives/C5UNMSU4R/p1511878493000062

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


More information about the wp-trac mailing list