Opened 7 years ago
Closed 7 years ago
#37135 closed enhancement (wontfix)
Fluent interface for WP_REST_Response class
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | REST API | Keywords: | |
Focuses: | Cc: |
Description
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.
Change History (2)
Note: See
TracTickets for help on using
tickets.
Given that we don't use fluent interfaces anywhere in WordPress, I don't think it's a good idea to have it here. I'm goign to close this out as #wontfix, but feel free to comment if any strongly objects.