FOSSology  4.7.1
Open Source License Compliance by Open Source Software
MenuHook.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2015 Siemens AG
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
8 namespace Fossology\Lib\UI;
9 
10 class MenuHook
11 {
16  public static function getAgentPluginNames($hook='Agents')
17  {
18  $maxDepth = 0;
19  $agentList = menu_find($hook, $maxDepth) ?: array();
20  $agentPluginNames = array();
21  if (is_array($agentList)) {
22  foreach ($agentList as $parmAgent) {
23  $agent = plugin_find_id($parmAgent->URI);
24  if (!empty($agent)) {
25  $agentPluginNames[] = $agent;
26  }
27  }
28  }
29  return $agentPluginNames;
30  }
31 
39  public static function rearrangeParmAgentsBeforeDecider(&$parmList)
40  {
41  $deciderKey = array_search('agent_decider', $parmList);
42  if ($deciderKey === false) {
43  return;
44  }
45 
46  $early = array();
47  foreach (array('agent_reuser', 'agent_scancode') as $name) {
48  $key = array_search($name, $parmList);
49  if ($key !== false && $key > $deciderKey) {
50  $early[] = $name;
51  unset($parmList[$key]);
52  }
53  }
54  if (empty($early)) {
55  return;
56  }
57 
58  $parmList = array_values($parmList);
59  array_splice($parmList, array_search('agent_decider', $parmList), 0, $early);
60  }
61 }
static getAgentPluginNames($hook='Agents')
Definition: MenuHook.php:16
static rearrangeParmAgentsBeforeDecider(&$parmList)
Definition: MenuHook.php:39
menu_find($Name, &$MaxDepth, $Menu=NULL)
Given a top-level menu name, find the list of sub-menus below it and max depth of menu.