From 6cccc6d4b36feee8b0acdae260d1ca747f94f36f Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 9 Jun 2014 18:58:32 -0700 Subject: [PATCH] CRM-14765 - CRM_Core_FileSearchInterface - Allow modules to define file-search mechanism --- CRM/Core/BAO/File.php | 17 +++++++++++++++++ CRM/Core/FileSearchInterface.php | 23 +++++++++++++++++++++++ CRM/Utils/Hook.php | 11 +++++++++++ 3 files changed, 51 insertions(+) create mode 100644 CRM/Core/FileSearchInterface.php diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index 78047e9e9f..3d0d59ab68 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -677,4 +677,21 @@ AND CEF.entity_id = %2"; } return $results; } + + /** + * Get a reference to the file-search service (if one is available). + * + * @return CRM_Core_FileSearchInterface|NULL + */ + static function getSearchService() { + $fileSearches = array(); + CRM_Utils_Hook::fileSearches($fileSearches); + + // use the first available search + foreach ($fileSearches as $fileSearch) { + /** @var $fileSearch CRM_Core_FileSearchInterface */ + return $fileSearch; + } + return NULL; + } } diff --git a/CRM/Core/FileSearchInterface.php b/CRM/Core/FileSearchInterface.php new file mode 100644 index 0000000000..8ee91ca042 --- /dev/null +++ b/CRM/Core/FileSearchInterface.php @@ -0,0 +1,23 @@ + $fileSearches + * @return mixed + */ + static function fileSearches(&$fileSearches) { + return self::singleton()->invoke(1, $fileSearches, + self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, + 'civicrm_fileSearches' + ); + } } -- 2.25.1