diff --git a/ext/search_kit/Civi/Search/SearchDisplayChecks.php b/ext/search_kit/Civi/Search/SearchDisplayChecks.php new file mode 100644 index 000000000000..6ac36c52b936 --- /dev/null +++ b/ext/search_kit/Civi/Search/SearchDisplayChecks.php @@ -0,0 +1,82 @@ + 'runChecks']; + } + + /** + * @see \CRM_Utils_Hook::check() + */ + public function runChecks(&$messages, $statusNames = [], $includeDisabled = FALSE) { + if (!empty($statusNames) && !preg_grep('/^' . preg_quote(static::PREFIX, '/') . '/', $statusNames)) { + return; + } + + $displays = SearchDisplay::get(FALSE) + ->addSelect('id', 'label', 'type', 'settings', 'saved_search_id', 'saved_search_id.api_entity', 'saved_search_id.api_params') + ->execute(); + foreach ($displays as $display) { + $issues = $this->validateSearchDisplay($display['saved_search_id.api_entity'], $display['saved_search_id.api_params'], $display['settings']); + if (!empty($issues)) { + $message = new \CRM_Utils_Check_Message( + static::PREFIX . $display['id'], + '
' . ts('This record appears to have invalid settings:') . '
' . + '%1
"', [1 => htmlentities($column['key'])]);
+ }
+ }
+
+ return $issues;
+ }
+
+}