From 481dac43f9de9c9fe1401667a11ebb7702e90dc9 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 26 Nov 2024 14:25:48 +0100 Subject: [PATCH] ObjectSuggestions: Add methods to restrict $customVarSources --- .../Web/Control/SearchBar/ObjectSuggestions.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php index 7630e016..3c4382fc 100644 --- a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php @@ -419,4 +419,18 @@ class ObjectSuggestions extends Suggestions } } } + + /** + * Reduce {@see $customVarSources} to only given relations to fetch variables from + * + * @param string[] $relations + * + * @return $this + */ + public function onlyWithCustomVarSources(array $relations): self + { + $this->customVarSources = array_intersect_key($this->customVarSources, array_flip($relations)); + + return $this; + } }