Merge pull request #20389 from eileenmcnaughton/tax
[civicrm-core.git] / ext / search_kit / search_kit.php
1 <?php
2
3 require_once 'search_kit.civix.php';
4
5 /**
6 * Implements hook_civicrm_config().
7 *
8 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config/
9 */
10 function search_kit_civicrm_config(&$config) {
11 _search_kit_civix_civicrm_config($config);
12 Civi::dispatcher()->addListener('hook_civicrm_alterAngular', ['\Civi\Search\AfformSearchMetadataInjector', 'preprocess'], 1000);
13 }
14
15 /**
16 * Implements hook_civicrm_xmlMenu().
17 *
18 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_xmlMenu
19 */
20 function search_kit_civicrm_xmlMenu(&$files) {
21 _search_kit_civix_civicrm_xmlMenu($files);
22 }
23
24 /**
25 * Implements hook_civicrm_managed().
26 *
27 * Generate a list of entities to create/deactivate/delete when this module
28 * is installed, disabled, uninstalled.
29 *
30 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_managed
31 */
32 function search_kit_civicrm_managed(&$entities) {
33 _search_kit_civix_civicrm_managed($entities);
34 }
35
36 /**
37 * Implements hook_civicrm_angularModules().
38 *
39 * Generate a list of Angular modules.
40 *
41 * Note: This hook only runs in CiviCRM 4.5+. It may
42 * use features only available in v4.6+.
43 *
44 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_angularModules
45 */
46 function search_kit_civicrm_angularModules(&$angularModules) {
47 _search_kit_civix_civicrm_angularModules($angularModules);
48 // Fetch all search tasks provided by other modules and add them as crmSearchTasks dependencies
49 $tasks = $dependencies = [];
50 $null = NULL;
51 CRM_Utils_Hook::singleton()->invoke(['tasks'], $tasks,
52 $null, $null, $null, $null, $null, 'civicrm_searchKitTasks'
53 );
54 foreach ($tasks as $entityTasks) {
55 foreach ($entityTasks as $task) {
56 if (isset($task['module']) && $task['module'] !== 'crmSearchTasks' &&
57 !in_array($task['module'], $angularModules['crmSearchTasks']['requires'], TRUE)
58 ) {
59 $angularModules['crmSearchTasks']['requires'][] = $task['module'];
60 }
61 }
62 }
63 }
64
65 /**
66 * Implements hook_civicrm_alterSettingsFolders().
67 *
68 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_alterSettingsFolders
69 */
70 function search_kit_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
71 _search_kit_civix_civicrm_alterSettingsFolders($metaDataFolders);
72 }
73
74 /**
75 * Implements hook_civicrm_entityTypes().
76 *
77 * Declare entity types provided by this module.
78 *
79 * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
80 */
81 function search_kit_civicrm_entityTypes(&$entityTypes) {
82 _search_kit_civix_civicrm_entityTypes($entityTypes);
83 }
84
85 /**
86 * Implements hook_civicrm_themes().
87 */
88 function search_kit_civicrm_themes(&$themes) {
89 _search_kit_civix_civicrm_themes($themes);
90 }
91
92 /**
93 * Implements hook_civicrm_pre().
94 */
95 function search_kit_civicrm_pre($op, $entity, $id, &$params) {
96 // Supply default name/label when creating new SearchDisplay
97 if ($entity === 'SearchDisplay' && $op === 'create') {
98 if (empty($params['label'])) {
99 $params['label'] = $params['name'];
100 }
101 elseif (empty($params['name'])) {
102 $params['name'] = \CRM_Utils_String::munge($params['label']);
103 }
104 }
105 }