Skip to content

Commit

Permalink
Customize default display for Countries
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Nov 16, 2022
1 parent d2fa320 commit 53f1708
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions Civi/Api4/Service/Autocomplete/CountryAutocompleteProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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 CountryAutocompleteProvider extends \Civi\Core\Service\AutoService implements HookInterface {

/**
* Provide default SearchDisplay for Country 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'] !== 'Country') {
return;
}
$e->display['settings'] = [
'sort' => [
['name', 'ASC'],
],
'columns' => [
[
'type' => 'field',
'key' => 'name',
],
[
'type' => 'field',
'key' => 'iso_code',
],
],
];
}

}

0 comments on commit 53f1708

Please sign in to comment.