-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-add deprecated url helpers with appropriate deprecation warnings t…
…o use search_state instead
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module Blacklight | ||
module DeprecatedUrlHelperBehavior | ||
extend Deprecation | ||
self.deprecation_horizon = 'blacklight 7.x' | ||
|
||
def params_for_search(*args, &block) | ||
source_params, params_to_merge = case args.length | ||
when 0 | ||
search_state.params_for_search | ||
when 1 | ||
search_state.params_for_search(args.first) | ||
when 2 | ||
Deprecation.warn(Blacklight::DeprecatedUrlHelperBehavior, 'Use Blacklight::SearchState.new(source_params).params_for_search instead') | ||
Blacklight::SearchState.new(args.first, blacklight_config).params_for_search(args.last) | ||
else | ||
raise ArgumentError.new "wrong number of arguments (#{args.length} for 0..2)" | ||
end | ||
end | ||
deprecation_deprecate :params_for_search | ||
|
||
def sanitize_search_params(source_params) | ||
Blacklight::Parameters.sanitize(source_params) | ||
end | ||
deprecation_deprecate :sanitize_search_params | ||
|
||
def reset_search_params(source_params) | ||
Blacklight::SearchState.new(source_params, blacklight_config).send(:reset_search_params) | ||
end | ||
deprecation_deprecate :reset_search_params | ||
|
||
def add_facet_params(field, item, source_params = nil) | ||
if source_params | ||
Deprecation.warn(Blacklight::DeprecatedUrlHelperBehavior, 'Use Blacklight::SearchState.new(source_params).add_facet_params instead') | ||
|
||
Blacklight::SearchState.new(source_params, blacklight_config).add_facet_params(field, item) | ||
else | ||
search_state.add_facet_params(field, item) | ||
end | ||
end | ||
deprecation_deprecate :add_facet_params | ||
|
||
def remove_facet_params(field, item, source_params = nil) | ||
if source_params | ||
Deprecation.warn(Blacklight::DeprecatedUrlHelperBehavior, 'Use Blacklight::SearchState.new(source_params).remove_facet_params instead') | ||
|
||
Blacklight::SearchState.new(source_params, blacklight_config).remove_facet_params(field, item) | ||
else | ||
search_state.remove_facet_params(field, item) | ||
end | ||
end | ||
deprecation_deprecate :remove_facet_params | ||
|
||
def add_facet_params_and_redirect(field, item) | ||
search_state.add_facet_params_and_redirect(field, item) | ||
end | ||
deprecation_deprecate :add_facet_params_and_redirect | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters