service-voice Posted July 4, 2018 Share Posted July 4, 2018 Hi, I'm having a problem with rebuilding the menu in whmcs. On version 7.4.1, this code works for me: <?php /** * Created by PhpStorm. * User: Artem * Date: 24.12.2017 * Time: 21:46 */ namespace AnonymousPayment\Controller; use \Menu; use AnonymousPayment\Controller\WHMCSClientController; class WHMCSMenuItemController { /** * @var \Knp\Menu\MenuItem; */ private static $PrimaryNavBar; public static function GetPrimaryNavBarStructure( $UserLogin ) { if ( $UserLogin ) { $_SESSION['uid'] = WHMCSClientController::GetFirstUserID(); } else { unset( $_SESSION['uid'] ); } self::$PrimaryNavBar = Menu::primaryNavbar(); run_hook( 'ClientAreaPrimaryNavbar', self::$PrimaryNavBar ); self::$PrimaryNavBar = self::$PrimaryNavBar->sort( self::$PrimaryNavBar ); foreach ( self::$PrimaryNavBar->getChildren() as $key => $val ) { $Structure[ $key ]['translate'] = $val->getLabel() . ' '; if ( $val->hasChildren() ) { foreach ( $val->getChildren() as $key2 => $val2 ) { $Structure[ $key ]['SumItem'][ $key2 ]['translate'] = $val2->getLabel(); } } } Menu::swap(); return $Structure; } } However, in the whmcs version 7.6.0 Beta1 this code does not work, the error occurs in "Menu :: swap ()", now it is required that I pass there the argument, I used this call to clear the built menu. I tried to pass this function as a parameter "Menu :: self ()", but this did not give the desired result. I tried to use "Menu :: clearResolvedInstances ()" however this also did not help. 0 Quote Link to comment Share on other sites More sharing options...
service-voice Posted July 7, 2018 Author Share Posted July 7, 2018 Someone has ideas how to create a menu for a guest, clear the built menu and create it again for an authorized user? I need this for the menu editor. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.