src-dev/Mouf/Menu/DocumentationMenuItem.php
private function getMenuTree() {
		
		if ($this->computed) {
			return parent::getChildren();
		}
		$this->computed = true;
		
		$children = $this->cache->get('documentationMenuItem');
		
		if ($children) {
			return $children;
		}
			
		if (isset($_REQUEST['selfedit']) && $_REQUEST['selfedit'] == 'true') {
			$selfedit = true;
		} else {
			$selfedit = false;
		}
		
		$composerService = new ComposerService($selfedit);
		
		$packages = $composerService->getLocalPackages();
		
		$tree = array();
	
		// Let's fill the menu with the packages.
		foreach ($packages as $package) {
			$name = $package->getName();
			if (strpos($name, '/') === false) {
				continue;
			}
			list($vendorName, $packageName) = explode('/', $name);
			
			$items = explode('.', $packageName);
			array_unshift($items, $vendorName);

			$node =& $tree;
			foreach ($items as $str) {
				if (!isset($node["children"][$str])) {
					$node["children"][$str] = array();
				}
				$node =& $node["children"][$str];
			}
			$node['package'] = $package;
		}
	
		$this->walkMenuTree($tree, '', $this);
		
		// Short lived cache (3 minutes).
		$this->cache->set('documentationMenuItem', parent::getChildren(), 180);
		
		return parent::getChildren();
	}
private function getMenuTree() {
		
		if ($this->computed) {
			return parent::getChildren();
		}
		$this->computed = true;
		
		$children = $this->cache->get('documentationMenuItem');
		
		if ($children) {
			return $children;
		}
			
		if (isset($_REQUEST['selfedit']) && $_REQUEST['selfedit'] == 'true') {
			$selfedit = true;
		} else {
			$selfedit = false;
		}
		
		$composerService = new ComposerService($selfedit);
		
		$packages = $composerService->getLocalPackages();
		
		$tree = array();
	
		// Let's fill the menu with the packages.
		foreach ($packages as $package) {
			$name = $package->getName();
			if (strpos($name, '/') === false) {
				continue;
			}
			list($vendorName, $packageName) = explode('/', $name);
			
			$items = explode('.', $packageName);
			array_unshift($items, $vendorName);

			$node =& $tree;
			foreach ($items as $str) {
				if (!isset($node["children"][$str])) {
					$node["children"][$str] = array();
				}
				$node =& $node["children"][$str];
			}
			$node['package'] = $package;
		}
	
		$this->walkMenuTree($tree, '', $this);
		
		// Short lived cache (3 minutes).
		$this->cache->set('documentationMenuItem', parent::getChildren(), 180);
		
		return parent::getChildren();
	}
private function getMenuTree ( ) { if ( $ this -> computed ) { return parent :: getChildren ( ) ; } $ this -> computed = true ; $ children = $ this -> cache -> get ( 'documentationMenuItem' ) ; if ( $ children ) { return $ children ; } if ( isset ( $ _REQUEST [ 'selfedit' ] ) && $ _REQUEST [ 'selfedit' ] == 'true' ) { $ selfedit = true ; } else { $ selfedit = false ; } $ composerService = new ComposerService ( $ selfedit ) ; $ packages = $ composerService -> getLocalPackages ( ) ; $ tree = array ( ) ; // Let's fill the menu with the packages. foreach ( $ packages as $ package ) { $ name = $ package -> getName ( ) ; if ( strpos ( $ name , '/' ) === false ) { continue ; } list ( $ vendorName , $ packageName ) = explode ( '/' , $ name ) ; $ items = explode ( '.' , $ packageName ) ; array_unshift ( $ items , $ vendorName ) ; $ node = & $ tree ; foreach ( $ items as $ str ) { if ( ! isset ( $ node [ "children" ] [ $ str ] ) ) { $ node [ "children" ] [ $ str ] = array ( ) ; } $ node = & $ node [ "children" ] [ $ str ] ; } $ node [ 'package' ] = $ package ; } $ this -> walkMenuTree ( $ tree , '' , $ this ) ; // Short lived cache (3 minutes). $ this -> cache -> set ( 'documentationMenuItem' , parent :: getChildren ( ) , 180 ) ; return parent :: getChildren ( ) ; }
Adds the packages menu to the menu.
Adds the packages menu to the menu .