PHP Класс Search\Model\Behavior\SearchBehavior

Наследование: extends Cake\ORM\Behavior
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$_manager Search\Manager Search Manager instance.

Защищенные свойства (Protected)

Свойство Тип Описание
$_defaultConfig array ### Options - searchConfigMethod Method name of the method that returns the filters.
$_isSearch boolean Internal flag to check whether the behavior modified the query.

Открытые методы

Метод Описание
filterParams ( array $params ) : array Returns search params nested in array with key _search for passing as options to find method.
findSearch ( Query $query, array $options ) : Query Callback fired from the controller.
isSearch ( ) : boolean Returns true if the findSearch call modified the query in a way that at least one search filter has been applied.
searchManager ( ) : Manager Returns the search filter manager.

Защищенные методы

Метод Описание
_extractParams ( array $params, Base[] $filters ) : array Extracts all parameters for wich a filter with a matching field name exists.
_flattenParams ( array $params ) : array Flattens a parameters array, so that possible aliased parameter keys that are provided in a nested fashion, are being grouped using flat keys.
_getAllFilters ( string | null $collection = 'default' ) : Base[] Gets all filters by the default or given collection from the search manager
_processFilters ( Base[] $filters, array $params, Query $query ) : Query Processes the given filters.

Описание методов

_extractParams() защищенный Метод

Extracts all parameters for wich a filter with a matching field name exists.
protected _extractParams ( array $params, Base[] $filters ) : array
$params array The parameters array to extract from.
$filters Search\Model\Filter\Base[] The filters to match against.
Результат array The extracted parameters.

_flattenParams() защищенный Метод

### Example: The following parameters array: [ 'Alias' => [ 'field' => 'value' 'otherField' => [ 'value', 'otherValue' ] ], 'field' => 'value' ] would return as [ 'Alias.field' => 'value', 'Alias.otherField' => [ 'value', 'otherValue' ], 'field' => 'value' ]
protected _flattenParams ( array $params ) : array
$params array The parameters array to flatten.
Результат array The flattened parameters array.

_getAllFilters() защищенный Метод

Gets all filters by the default or given collection from the search manager
protected _getAllFilters ( string | null $collection = 'default' ) : Base[]
$collection string | null name of collection
Результат Search\Model\Filter\Base[] An array of filters for the defined fields.

_processFilters() защищенный Метод

Processes the given filters.
protected _processFilters ( Base[] $filters, array $params, Query $query ) : Query
$filters Search\Model\Filter\Base[] The filters to process.
$params array The parameters to pass to the filters.
$query Cake\ORM\Query The query to pass to the filters.
Результат Cake\ORM\Query The query processed by the filters.

filterParams() публичный Метод

Returns search params nested in array with key _search for passing as options to find method.
Устаревший: 2.0.0 You can directly call find like `find('search', ['search' => $this->request->query])`
public filterParams ( array $params ) : array
$params array A key value list of search parameters to use for a search.
Результат array

findSearch() публичный Метод

Callback fired from the controller.
public findSearch ( Query $query, array $options ) : Query
$query Cake\ORM\Query Query.
$options array The options for the find. - `search`: Array of search arguments. - `collection`: Filter collection name.
Результат Cake\ORM\Query The Query object used in pagination.

isSearch() публичный Метод

Returns true if the findSearch call modified the query in a way that at least one search filter has been applied.
public isSearch ( ) : boolean
Результат boolean

searchManager() публичный Метод

Returns the search filter manager.
public searchManager ( ) : Manager
Результат Search\Manager

Описание свойств

$_defaultConfig защищенное свойство

### Options - searchConfigMethod Method name of the method that returns the filters.
protected array $_defaultConfig
Результат array

$_isSearch защищенное свойство

Internal flag to check whether the behavior modified the query.
protected bool $_isSearch
Результат boolean

$_manager публичное свойство

Search Manager instance.
public Manager,Search $_manager
Результат Search\Manager