3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Delegate query functions based on hook system.
21 class CRM_Contact_BAO_Query_Hook
{
26 * @var CRM_Contact_BAO_Query_Interface[]
28 protected $_queryObjects = NULL;
31 * Singleton function used to manage this object.
35 public static function singleton() {
36 static $singleton = NULL;
38 $singleton = new CRM_Contact_BAO_Query_Hook();
44 * Get or build the list of search objects (via hook).
47 * Array of CRM_Contact_BAO_Query_Interface objects
49 public function getSearchQueryObjects() {
50 if ($this->_queryObjects
=== NULL) {
51 $this->_queryObjects
= [];
52 CRM_Utils_Hook
::queryObjects($this->_queryObjects
, 'Contact');
54 return $this->_queryObjects
;
60 public function &getFields() {
62 foreach (self
::getSearchQueryObjects() as $obj) {
63 $flds = $obj->getFields();
64 $extFields = array_merge($extFields, $flds);
71 * @param $fieldOptions
73 public function alterSearchBuilderOptions(&$apiEntities, &$fieldOptions) {
74 foreach (self
::getSearchQueryObjects() as $obj) {
75 $obj->alterSearchBuilderOptions($apiEntities, $fieldOptions);
82 * @param string $query
83 * @param string $fnName
85 public function alterSearchQuery(&$query, $fnName) {
86 foreach (self
::getSearchQueryObjects() as $obj) {
87 $obj->$fnName($query);
92 * @param string $fieldName
98 public function buildSearchfrom($fieldName, $mode, $side) {
100 foreach (self
::getSearchQueryObjects() as $obj) {
101 $from .= $obj->from($fieldName, $mode, $side);
109 public function setTableDependency(&$tables) {
110 foreach (self
::getSearchQueryObjects() as $obj) {
111 $obj->setTableDependency($tables);
118 public function registerAdvancedSearchPane(&$panes) {
119 foreach (self
::getSearchQueryObjects() as $obj) {
120 $obj->registerAdvancedSearchPane($panes);
127 public function getPanesMapper(&$panes) {
128 foreach (self
::getSearchQueryObjects() as $obj) {
129 $obj->getPanesMapper($panes);
134 * @param CRM_Core_Form $form
137 public function buildAdvancedSearchPaneForm(&$form, $type) {
138 foreach (self
::getSearchQueryObjects() as $obj) {
139 $obj->buildAdvancedSearchPaneForm($form, $type);
144 * @param $paneTemplatePathArray
147 public function setAdvancedSearchPaneTemplatePath(&$paneTemplatePathArray, $type) {
148 foreach (self
::getSearchQueryObjects() as $obj) {
149 $obj->setAdvancedSearchPaneTemplatePath($paneTemplatePathArray, $type);