Jump to content

Whmcs menu rebuild


Recommended Posts

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated