Commit | Line | Data |
---|---|---|
e7515b5b CW |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
6 | | This work is published under the GNU AGPLv3 license with some | | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
9 | +--------------------------------------------------------------------+ | |
10 | */ | |
11 | ||
12 | namespace Civi\Search; | |
13 | ||
14 | /** | |
15 | * Class Display | |
16 | * @package Civi\Search | |
17 | */ | |
18 | class Display { | |
19 | ||
20 | /** | |
21 | * @return array | |
22 | */ | |
ecb9d1eb CW |
23 | public static function getPartials($moduleName, $module) { |
24 | $partials = []; | |
25 | foreach (self::getDisplayTypes(['id', 'name']) as $type) { | |
26 | $partials["~/$moduleName/displayType/{$type['id']}.html"] = | |
a4321c5d | 27 | '<' . $type['name'] . ' api-entity="{{:: $ctrl.apiEntity }}" search="$ctrl.searchName" display="$ctrl.display.name" settings="$ctrl.display.settings" filters="$ctrl.filters"></' . $type['name'] . '>'; |
ecb9d1eb CW |
28 | } |
29 | return $partials; | |
e7515b5b CW |
30 | } |
31 | ||
32 | /** | |
e7515b5b CW |
33 | * @return array |
34 | */ | |
35 | public static function getDisplayTypes(array $props):array { | |
36 | try { | |
37 | return \Civi\Api4\SearchDisplay::getFields(FALSE) | |
ecb9d1eb | 38 | ->setLoadOptions(array_diff($props, ['tag'])) |
e7515b5b CW |
39 | ->addWhere('name', '=', 'type') |
40 | ->execute() | |
41 | ->first()['options']; | |
42 | } | |
43 | catch (\Exception $e) { | |
44 | return []; | |
45 | } | |
46 | } | |
47 | ||
48 | } |