mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 19:54:14 +08:00
DEV: Remove deprecated arguments to Plugin::Instande#add_api_parameter_route (#22736)
We deprecated the keywords method, route, and format (replaced with methods, actions, and formats respectively) as parameters to Plugin::Instance#add_api_parameter_route, marked for removal in 2.7. This PR deletes them.
This commit is contained in:
@ -971,36 +971,7 @@ class Plugin::Instance
|
|||||||
#
|
#
|
||||||
# See Auth::DefaultCurrentUserProvider::PARAMETER_API_PATTERNS for more examples
|
# See Auth::DefaultCurrentUserProvider::PARAMETER_API_PATTERNS for more examples
|
||||||
# and Auth::DefaultCurrentUserProvider#api_parameter_allowed? for implementation
|
# and Auth::DefaultCurrentUserProvider#api_parameter_allowed? for implementation
|
||||||
def add_api_parameter_route(
|
def add_api_parameter_route(methods: nil, actions: nil, formats: nil)
|
||||||
method: nil,
|
|
||||||
methods: nil,
|
|
||||||
route: nil,
|
|
||||||
actions: nil,
|
|
||||||
format: nil,
|
|
||||||
formats: nil
|
|
||||||
)
|
|
||||||
if Array(format).include?("*")
|
|
||||||
Discourse.deprecate(
|
|
||||||
"* is no longer a valid api_parameter_route format matcher. Use `nil` instead",
|
|
||||||
drop_from: "2.7",
|
|
||||||
raise_error: true,
|
|
||||||
)
|
|
||||||
# Old API used * as wildcard. New api uses `nil`
|
|
||||||
format = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
# Backwards compatibility with old parameter names:
|
|
||||||
if method || route || format
|
|
||||||
Discourse.deprecate(
|
|
||||||
"method, route and format parameters for api_parameter_routes are deprecated. Use methods, actions and formats instead.",
|
|
||||||
drop_from: "2.7",
|
|
||||||
raise_error: true,
|
|
||||||
)
|
|
||||||
methods ||= method
|
|
||||||
actions ||= route
|
|
||||||
formats ||= format
|
|
||||||
end
|
|
||||||
|
|
||||||
DiscoursePluginRegistry.register_api_parameter_route(
|
DiscoursePluginRegistry.register_api_parameter_route(
|
||||||
RouteMatcher.new(methods: methods, actions: actions, formats: formats),
|
RouteMatcher.new(methods: methods, actions: actions, formats: formats),
|
||||||
self,
|
self,
|
||||||
|
Reference in New Issue
Block a user