Passed
Push — master ( c0a3a7...3b84a4 )
by Jeroen
58:51
created

engine/lib/search.php (1 issue)

1
<?php
2
3
/**
4
 * Basic Elgg search hooks.
5
 */
6
7
/**
8
 * Returns search results as an array of entities, as a batch, or a count,
9
 * depending on parameters given.
10
 *
11
 * @param array $options Search parameters
12
 *                       Accepts all
13
 *                       options supported
14
 *                       by {@link
15
 *                       elgg_get_entities()}
16
 *
17
 * @option string $query         Search query
18
 * @option string $type          Entity type. Required if no search type is set
19
 * @option string $search_type   Custom search type. Required if no type is set
20
 * @option array  $fields        An array of fields to search in
21
 * @option string $sort          An array containing 'property', 'property_type', 'direction' and 'signed'
22
 * @option bool   $partial_match Allow partial matches, e.g. find 'elgg' when search for 'el'
23
 * @option bool   $tokenize      Break down search query into tokens,
24
 *                               e.g. find 'elgg has been released' when searching for 'elgg released'
25
 *
26
 * @return ElggBatch|ElggEntity[]|int|false
27
 *
28
 * @see    elgg_get_entities()
29
 */
30
function elgg_search(array $options = []) {
31
	try {
32 197
		return _elgg_services()->search->search($options);
33
	} catch (InvalidParameterException $e) {
34
		return false;
35
	}
36
}
37
38
/**
39
 * Initializes default search hooks
40
 * @return void
41
 * @since 3.0
42
 */
43
function _elgg_search_init() {
44 31
	elgg_register_plugin_hook_handler('search:fields', 'user', \Elgg\Search\UserSearchFieldsHandler::class);
45 31
	elgg_register_plugin_hook_handler('search:fields', 'object', \Elgg\Search\ObjectSearchFieldsHandler::class);
46 31
	elgg_register_plugin_hook_handler('search:fields', 'group', \Elgg\Search\GroupSearchFieldsHandler::class);
47 31
}
48
49
return function (\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
1 ignored issue
show
The parameter $hooks is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

49
return function (\Elgg\EventsService $events, /** @scrutinizer ignore-unused */ \Elgg\HooksRegistrationService $hooks) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50 18
	$events->registerHandler('init', 'system', '_elgg_search_init');
51
};
52