SearchCriteria
final class SearchCriteria (View source)
Value object holding the search parameters the search page works with.
The parameters are resolved from three precedence layers, highest first:
- Filters embedded in the query itself ("type:txt", "content:spf") beat the corresponding form fields and also force-enable record search, since a typed-in filter can only apply to records.
- Submitted form fields (checkbox toggles, type/content filter dropdowns) beat the defaults; an unsubmitted checkbox means "off".
- Defaults apply when the form was not submitted at all (initial page load): zones, records, wildcard and reverse search on, comments off, no filters.
Two special rules sit on top:
- A bare IP query always searches records and reverse zones, even when those boxes were not ticked - that is almost certainly a PTR lookup.
- When record search ends up disabled, the type/content filters are cleared, as they only ever apply to records.
Constants
| private MAX_RETURN_VALUE_LENGTH |
|
Methods
Build the criteria from a submitted search form, or the defaults when the page was requested without a submission.
The resolved parameters in the exact shape the search services and templates consume; 'displayed_query' is present only for submissions.
This search, plus the result pages and page sizes being shown, as the arguments that repeat it with a GET to /search (see returnArgs()).
Whitelists the search arguments a page carries to return to the search results: known keys with scalar values only, shaped like a submitted search form (unticked boxes absent). Empty when there is no usable search.
Details
static SearchCriteria
fromRequest(array|null $postParams)
Build the criteria from a submitted search form, or the defaults when the page was requested without a submission.
array
toArray()
The resolved parameters in the exact shape the search services and templates consume; 'displayed_query' is present only for submissions.
array
toReturnArgs(int $zonesPage, int $recordsPage, int $zonesRows, int $recordsRows)
This search, plus the result pages and page sizes being shown, as the arguments that repeat it with a GET to /search (see returnArgs()).
static array
returnArgs(mixed $params)
Whitelists the search arguments a page carries to return to the search results: known keys with scalar values only, shaped like a submitted search form (unticked boxes absent). Empty when there is no usable search.
The result is only ever query-string arguments for the fixed /search path, never a URL, so it cannot redirect anywhere else.