Skip to content

Commit

Permalink
WIP4
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed Aug 27, 2024
1 parent 4ca6fd7 commit 00254f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
12 changes: 3 additions & 9 deletions library/Icingadb/Hook/CustomVarEnricherHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ abstract class CustomVarEnricherHook
{
use HookUtils;

/**
* Return the grouped custom vars
*
* @return array
*/
abstract public function getGroups(): array;

/**
* Return enriched vars in the following format
* [label => enriched custom var]
Expand All @@ -39,8 +32,9 @@ public static function prepareEnrichedCustomVars(array $vars, Model $object): ar
foreach (Hook::all('Icingadb/CustomVarEnricher') as $hook) {
/** @var self $hook */
try {
$enrichedVars[] = $hook->enrichCustomVars($vars, $object);
$groups[] = $hook->getGroups();
list($hookVars, $hookGroups) = $hook->enrichCustomVars($vars, $object);
$enrichedVars[] = $hookVars;
$groups[] = $hookGroups;
} catch (Throwable $e) {
Logger::error('Failed to load hook %s:', get_class($hook), $e);
}
Expand Down
7 changes: 1 addition & 6 deletions library/Icingadb/ProvidedHook/Icingadb/CustomVarEnricher.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function enrichCustomVars(array &$vars, Model $object): array
$newVars = array_merge([], ...$newVars);
}

return $newVars;
return [$newVars, $this->groups];
}

/**
Expand Down Expand Up @@ -159,9 +159,4 @@ private function buildDataListMap(DbConnection $db)
}
}
}

public function getGroups(): array
{
return $this->groups;
}
}

0 comments on commit 00254f1

Please sign in to comment.