SearchController
extends ControllerBase
in package
Search controller
Search accepts the following parameters via GET:
- keywords - search keywords
- order - search sort, default is published time, must be a valid property
- direction - sort direction, can be
asc
ordesc
, default is newest first (desc) - tag - comma separated list of inclusive tags to search
- author - comma separated list of inclusive authors to search
- title - items title, headline, filename
- begin - published begin time, in the form of YYYYMMDD
- end - published end time, in the form of YYYYMMDD
- type - content type, article, post, media - by default searches ALL types
Search can also work in compatibility mode if a=1
or q=
are present in the query
string. In that case, the following substitutions are made:
IF a=1
is present:
- keywords -> s
- order -> d
- direction -> o
- tag -> tg
- author -> au
- title -> ti
- type -> ty
- ts_* -> begin
- te_* -> end
IF q=string
is present:
- keywords -> q
- order -> "published_at"
- direction -> "desc"
- tag -> NULL
- author -> NULL
- title -> NULL
- type -> NULL
- ts_* -> NULL
- te_* -> NULL
Table of Contents
- indexAction() : mixed
- Search action, by URLs in the form of:
- initialize() : mixed
- Initialize response headers
- buildItemCollection() : array<string|int, mixed>
- Build collection of items. Casts search results as proper model types.
- buildPagination() : Pagination
- Build the pagination object
- enableCompatibilityView() : bool
- Enables path to Gryphon compatible view, if the view exists AND enableCompatibility is on.
- getHttpCodeDescription() : mixed
- getJsonData() : array<string|int, mixed>
- Fetch POSTed/PUTed json data
- getRequestSegments() : mixed
- Return rewrite url segments
- terminateWithView() : mixed
- Terminate the action with a view partial. Will dump output directly to browser, but return the action allowing process to continue.
- handleSearch() : array<string|int, mixed>
- Handle search direct on CEO search service
Methods
indexAction()
Search action, by URLs in the form of:
public
indexAction() : mixed
-
search
Returns the following items to the view:
- didSearch - boolean
- total - integer
- items - collection of objects Article, Post, Media, Result
- pagination - Pagination
- searchParams - array of search parameters, see above
Looks for templates in the following order:
- gryphon/search/advanced.tpl - Compatibility mode
- search/index.twig
Search items implement the Searchable Trait
Tags
Return values
mixed —initialize()
Initialize response headers
public
initialize() : mixed
Return values
mixed —buildItemCollection()
Build collection of items. Casts search results as proper model types.
protected
buildItemCollection(array<string|int, mixed> $matches) : array<string|int, mixed>
If model type cannot be determined, will cast as \Ceo\Search\Result type which implements the \Ceo\Traits\Searchable trait.
Parameters
- $matches : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —buildPagination()
Build the pagination object
protected
buildPagination(mixed $props, mixed $searchParams) : Pagination
Parameters
- $props : mixed
- $searchParams : mixed
Tags
Return values
Pagination —enableCompatibilityView()
Enables path to Gryphon compatible view, if the view exists AND enableCompatibility is on.
protected
enableCompatibilityView(string $view) : bool
NOTE: This will mutate the internal view.
Parameters
- $view : string
Return values
bool —getHttpCodeDescription()
protected
getHttpCodeDescription(mixed $code) : mixed
Parameters
- $code : mixed
Return values
mixed —getJsonData()
Fetch POSTed/PUTed json data
protected
getJsonData() : array<string|int, mixed>
Return values
array<string|int, mixed> —getRequestSegments()
Return rewrite url segments
protected
getRequestSegments([mixed $i = null ]) : mixed
Parameters
- $i : mixed = null
Return values
mixed —either all segments as array, or single segment
terminateWithView()
Terminate the action with a view partial. Will dump output directly to browser, but return the action allowing process to continue.
protected
terminateWithView(string $view[, array<string|int, mixed> $params = [] ][, array<string|int, mixed> $headers = [] ]) : mixed
Parameters
- $view : string
-
path
- $params : array<string|int, mixed> = []
-
view params
- $headers : array<string|int, mixed> = []
-
optional headers
Return values
mixed —handleSearch()
Handle search direct on CEO search service
private
handleSearch([mixed $props = [] ]) : array<string|int, mixed>
Parameters
- $props : mixed = []