[wp-trac] [WordPress Trac] #39851: WP_REST_Posts_Controller::get_items() has too many concerns

WordPress Trac noreply at wordpress.org
Sat Feb 11 23:20:40 UTC 2017


#39851: WP_REST_Posts_Controller::get_items() has too many concerns
--------------------------+-----------------------------
 Reporter:  Shelob9       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  REST API      |    Version:  4.7
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I've written a bunch of custom endpoints that return collections of posts
 of one or more post types. I'd like my responses to be the same
 formatting, body and header as the default post routes provide. This
 allows for a client designed to consume default routes to be more easily
 modified to use custom routes.

 Achieving this with a subclass of WP_REST_Posts_Controller still requires
 some cut and paste for collections of posts, since the get_items() method
 has way too many concerns. I'd like to break out the preparing of response
 body, as well as response header into separate methods, so that they can
 be used with different types of requests or ways to create arrays of
 WP_Post objects, while still providing a consistent response.

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


More information about the wp-trac mailing list