Make sure only the active branch is visible

@param array $activeBranch Of \Gems_Menu_Menu Abstract items
@return \Gems_Menu_MenuAbstract (continuation pattern)
494821
protected function setBranchVisible(array $activeBranch)
    {
        parent::setBranchVisible($activeBranch);

        $child  = end($activeBranch);
        $store  = self::_getSessionStore($this->get('label'));
        $contr  = $child->get('controller');
        $action = $child->get('action');

        $store->controller = $contr;
        $store->action = $action;
        $this->set('controller', $contr);
        $this->set('action', $action);

        return $this;
    }
1084938
public function isActive($active = true)
    {
        if (! is_bool($active)) {
            $active = false;
        }
        $this->isActive = $active;

        return $this;
    }
343693
public function getCurrentBranch()
    {
        $branches = $this->getClient()->run($this, 'branch');
        $branches = explode("\n", $branches);

        foreach ($branches as $branch) {
            if ('*' === $branch[0]) {
                if (preg_match('/(detached|no branch)/', $branch)) {
                    return null;
                }

                return substr($branch, 2);
            }
        }
    }
459548
func (c *ModelCommandBase) SetActiveBranch(branchName string) error {
	_, modelDetails, err := c.ModelDetails()
	if err != nil {
		return errors.Annotate(err, "getting model details")
	}
	modelDetails.ActiveBranch = branchName
	if err = c.store.UpdateModel(c._controllerName, c._modelName, *modelDetails); err != nil {
		return err
	}
	c._activeBranch = branchName
	return nil
}
798446
public function getBranchesList($keep_asterisk = false)
    {
        $branchArray = explode("\n", $this->run("branch"));
        foreach ($branchArray as $i => &$branch) {
            $branch = trim($branch);
            if (! $keep_asterisk) {
                $branch = str_replace("* ", "", $branch);
            }
            if ($branch == "") {
                unset($branchArray[$i]);
            }
        }
        return $branchArray;
    }
1315771
protected function selectActiveNode()
    {
        $keys = array_keys($this->nodes);
        $this->activeNode = $keys[rand(0, count($keys) - 1)];
    }
276017
public function addBranch($name, array $commands, $path = null, array $options = array())
    {
        $path = $path ? $path : $this->path;

        if (!array_key_exists($name, $this->branchesList)) {
            $this->logger->info('Add branch '.$name.', path: '.$path);

            $branch = new Branch($this, $name, $path, $options, $this->options);
            $branch->addCommand($commands);
            $this->branchesList[$name] = $branch;
        }

        return $this;
    }
1146095
public function active()
    {
        $args = func_get_args();
        $this->active = current($args);

        if (func_num_args() > 1) {
            $this->active = $args;
        }

        return $this;
    }
190754
protected function getTagFromBranch($branch)
    {
        $git  = new GitRepository($this->input->getArgument('git-dir'));
        $tag  = trim($git->describe()->tags()->always()->execute($branch));
        $hash = trim($git->revParse()->short(false)->execute($branch));
        return $hash !== $tag ? $tag : null;
    }
771388
public function toActiveBranchElement()
    {
        $request    = $this->_getOriginalRequest();
        $activePath = $this->_findPath($request);

        if (! $activePath) {
            return null;
        }

        $this->setBranchVisible($activePath);

        $activeItem = array_pop($activePath);

        if (! $activeItem instanceof \Gems_Menu_SubMenuItem) {
            return null;
        }
        // \MUtil_Echo::track($activeItem->get('label'));

        $parameterSources[] = $request;

        if ($this->_menuParameters) {
            $parameterSources[] = $this->_menuParameters;
        }

        $source = new \Gems_Menu_ParameterCollector($parameterSources);
        // self::$verbose = true;

        $nav = $this->_toNavigationArray($source);

        $ul = $this->renderFirst();

        foreach ($nav as $item => $sub) {
            if ($sub['label'] === $activeItem->get('label')) {

                if (isset($sub['pages'])) {
                    $this->renderItems($ul, $sub['pages'], true);
                }

                return $ul;
            }
        }

        return null;
    }
816518
protected function _cloneActiveContext($active_ctx) {
    $child = new stdClass();
    $child->{'@base'} = $active_ctx->{'@base'};
    $child->mappings = self::copy($active_ctx->mappings);
    $child->inverse = null;
    if(property_exists($active_ctx, '@language')) {
      $child->{'@language'} = $active_ctx->{'@language'};
    }
    if(property_exists($active_ctx, '@vocab')) {
      $child->{'@vocab'} = $active_ctx->{'@vocab'};
    }
    return $child;
  }
836447
protected function setActiveFacets($activeFacets = [])
    {
        $path = $this->prefixWithNamespace('filter');
        $this->argumentsAccessor->set($path, $activeFacets);

        return $this;
    }
609409
public static function validateBranch($branch, VersionParser $parser = null)
    {
        if (null === $parser) {
            $parser = new VersionParser();
        }

        $normalize = $parser->normalizeBranch($branch);

        if (false !== strpos($normalize, '.9999999-dev')) {
            return false;
        }

        return $normalize;
    }
62304
public static function activeMenu($menu = null)
    {
        if ($menu === null) {
            $activeMenu = self::$_activeMenu;
        } else {
            $activeMenu = $menu;
        }

        if (!array_key_exists($activeMenu, self::$_items)) {
            self::$_items[$activeMenu] = [];
        }

        self::$_activeMenu = $activeMenu;
        return $activeMenu;
    }
387325
public function showMenu($menu, $layout = null, $activeLink= null) {
		
		if( $layout === null ) {
			$layout = defined('LAYOUT_MENU') ? LAYOUT_MENU : 'menu-default';
		}
		if( !$activeLink === null) {
			$activeLink = get_current_link();
		}
		
		$env = array('menu' => $menu, 'items' => array());
		$items = $this->getMenuItems($menu);
		if( empty($items) ) {
			return false;
		}
		foreach( $items as $itemConf ) {
			if( empty($itemConf) ) {
				continue;
			}
			if( $itemConf[0] === '\\' ) {
				// Callback
				$env['items'] = array_merge($env['items'], call_user_func($itemConf));
				
			} else {
				if( $itemConf[0] === '#' ) {
					// Static link with link & label hardcoded
					// Can not be active
					$itemParts = explodeList('|', substr($itemConf, 1), 2);
					$item = new MenuItem($itemParts[0], t($itemParts[1]));
					
				} else {
					// TODO: Allow {var:value} for values, or use a YAML config ?
					$routeName = $itemConf;
					
					/* @var $route HTTPRoute */
					$route = Route::getRoute($routeName);
					
					// Does not exist or is not acessible
					if( !$route || !$route->isAccessible()) {
						continue;
					}
					
					$item = new MenuItem(u($routeName), t($routeName));
					$item->setRoute($routeName);
				}
				$env['items'][] = $item;
			}
		}
		foreach( $env['items'] as $item) {
			if( $activeLink === $item->getLink() ) {
				$item->setActive();
			}
		}
		$this->display($layout, $env);
	}
599381
private function compare_to_current_branch($path, $branch) {

		$current = $this->get_child_current_branch($path);
		
		if(str_replace("origin/", "", $branch) == $current['current_branch']) {
			return "selected";
		} else {
			return "";
		}

		return "";
	}
1236169
public function setActive($active)
    {
        if (is_callable($active) || is_string($active)) {
            $condition = $active;
        } else {
            $condition = null;
        }

        $this->activeCondition = $condition;

        return parent::setActive($active);
    }