/
ParticipantAutocompleteProvider.php
57 lines (51 loc) · 1.65 KB
/
ParticipantAutocompleteProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
namespace Civi\Api4\Service\Autocomplete;
use Civi\Core\Event\GenericHookEvent;
use Civi\Core\HookInterface;
/**
* @service
* @internal
*/
class ParticipantAutocompleteProvider extends \Civi\Core\Service\AutoService implements HookInterface {
/**
* Provide default SearchDisplay for Participant autocompletes
*
* @param \Civi\Core\Event\GenericHookEvent $e
*/
public static function on_civi_search_defaultDisplay(GenericHookEvent $e) {
if ($e->display['settings'] || $e->display['type'] !== 'autocomplete' || $e->savedSearch['api_entity'] !== 'Participant') {
return;
}
$e->display['settings'] = [
'sort' => [
['contact_id.sort_name', 'ASC'],
['event_id.title', 'ASC'],
],
'columns' => [
[
'type' => 'field',
'key' => 'contact_id.display_name',
'rewrite' => '[contact_id.display_name] - [event_id.title]',
],
[
'type' => 'field',
'key' => 'role_id:label',
'rewrite' => '#[id] [role_id:label]',
],
[
'type' => 'field',
'key' => 'status_id:label',
],
],
];
}
}