passes the menu as a reference to the on Events instead of using a callback function

This commit is contained in:
SimonGschnell
2024-07-09 10:37:43 +02:00
parent 0347f8bf02
commit 8a44a9e1af
@@ -249,6 +249,7 @@ class LvMenu extends FHCAPI_Controller
// Addons Menu Logic // Addons Menu Logic
// ########################################################################################## // ##########################################################################################
$params = [ $params = [
'user'=>$user,
'lvid'=>$lvid, 'lvid'=>$lvid,
'studiensemester_kurzbz'=>$studiensemester_kurzbz, 'studiensemester_kurzbz'=>$studiensemester_kurzbz,
'studiengang_kz'=>$studiengang_kz, 'studiengang_kz'=>$studiengang_kz,
@@ -264,10 +265,8 @@ class LvMenu extends FHCAPI_Controller
Events::trigger('lvMenuBuild', Events::trigger('lvMenuBuild',
// callback function for the onEvents to add newValues to the $menu // callback function for the onEvents to add newValues to the $menu
function ($addonMenu) use (&$menu) { function & () use (&$menu) {
foreach($addonMenu as $m){ return $menu;
$menu[]= $m;
}
}, },
$params $params
); );
@@ -276,21 +275,15 @@ class LvMenu extends FHCAPI_Controller
// Menu sortieren // Menu sortieren
// ########################################################################################## // ##########################################################################################
foreach ($menu as $key => $row){ foreach ($menu as $key => $row){
if(isset($row['position'])){ $pos[$key] = $row['position'];
$pos[$key] = $row['position'];
}
} }
$sortable_menu = array_filter($menu, function($element){ array_multisort($pos, SORT_ASC, SORT_NUMERIC, $menu);
return isset($element['position']);
});
array_multisort($pos, SORT_ASC, SORT_NUMERIC, $sortable_menu);
// HTTP response // HTTP response
// ########################################################################################## // ##########################################################################################
$this->terminateWithSuccess($sortable_menu); $this->terminateWithSuccess($menu);
} }