[wp-trac] [WordPress Trac] #37135: Fluent interface for WP_REST_Response class
WordPress Trac
noreply at wordpress.org
Tue Jun 21 08:47:01 UTC 2016
#37135: Fluent interface for WP_REST_Response class
-------------------------+-----------------------------
Reporter: tfrommen | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Keywords:
Focuses: |
-------------------------+-----------------------------
Hi there,
it would be really handy to give (at least) the `WP_REST_Response` class a
fluent interface. This is as easy as `return $this` (as well as adapting
the according PHPDoc annotation) in the following methods:
- `WP_REST_Response::add_link()`;
- `WP_REST_Response::add_links()`;
- `WP_REST_Response::link_header()`;
- `WP_REST_Response::set_matched_handler()`;
- `WP_REST_Response::set_matched_route()`.
Why?
So one can do this:
`return ( new WP_REST_Response() )->set_matched_route( /* */ )->add_links(
/* */ );`
Happy to provide the according patch, if there's an interest in that.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/37135>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list