Try to guess which module is parent for current page
and remain sidebarmenu accordion opened.
@param array $item
@return bool
541317
protected function guessModule(array $item, $parentUrl = null)
    {
        $result = false;
        $moduleId = Yii::$app->controller->module->id;
        $parentModuleId = $this->getModuleName($parentUrl);
        if (!empty($item['items'])) {
            foreach ($item['items'] as $i) {
                if (isset($i['url'])) {
                    $itemModuleName = $this->getModuleName(reset($i['url']));
                    if ($itemModuleName === $moduleId && $parentModuleId === $moduleId) {
                        $result = true;
                        break;
                    }
                }
            }
        }

        return $result;
    }
1155322
public function isParentOf(Geo $item){
        return ($this->left < $item->left) && ($this->right > $item->right) && ($this->depth == $item->depth-1);
    }
825149
public function shouldBeIncluded($item)
    {
        if (!is_object($item)) {
            return false;
        }

        $pageId = $this->getPageId($item);
        $showInMenu = get_field('hide_in_menu', $pageId) ? !get_field('hide_in_menu', $pageId) : true;
        $isNotTopLevelItem = !($item->post_type === 'page' && isset($item->post_parent) && $item->post_parent === 0);
        $showTopLevel = $this->args['include_top_level'];

        return ($showTopLevel || $isNotTopLevelItem) && $showInMenu;
    }
773605
public function isMainMenuItemActive($item)
    {
        return $this->contextOwner == $item->owner && $this->contextMainMenuItemCode == $item->code;
    }
576003
private function _isLink($item): bool
	{
		if ($item === null) {
			return true;
		} elseif (is_array($item)) {
			return !is_array(current($item));
		} else {
			throw new \InvalidArgumentException('Cms menu items is wrong in config.neon');
		}
	}
1134034
protected function filterItem(array $item, array $options)
    {
        if ($options['filter']) {
            $f = call_user_func($options['filter'], $item);
            if ($f) {
                return $f;
            }
        }
        if (!empty($item['class'])) {
            $result = $this->filterByClass($item, $options);
            if ($result !== false) {
                return $result;
            }
        }
        if (!empty($item['file'])) {
            return $this->filterByFile($item, $options);
        }
        return self::FILTER_SKIP;
    }
754981
protected function checkList($item)
	{
		$inList = in_array($item, $this->list);
		
		$allow = null;
		
		if ($this->mode == self::MODE_BLACKLIST) {
			$allow = ! $inList;
		} else {
			$allow = $inList;
		}
		
		return $allow;
	}
560926
public function current($item, $level = null)
    {
        if (is_null($item)) {
            return null;
        }

        if (!$item instanceof MenuItem) {
            throw new \UnexpectedValueException(sprintf('$ITEM must be \Knp\Menu\MenuItem not "%s"', get_class($item)));
        }

        /** @var MenuItem $child */
        foreach ($item->getChildren() as $child) {
            if (
                (null !== $this->matcher && $this->matcher->isAncestor($child))
             || (null === $this->matcher && $child->isCurrentAncestor())
            ) {
                if ($level !== null and $level == $child->getLevel()) {
                    return $child;
                }

                return $this->current($child);
            }

            if (
                (null !== $this->matcher && $this->matcher->isCurrent($child))
             || (null === $this->matcher && $child->isCurrent())
            ) {
                return $child;
            }
        }

        return null;
    }
1211255
private function menuHelper($item)
    {
        // recurse into submenus
        if (isset($item['submenu']) && is_array($item['submenu'])) {
            $item['submenu'] = $this->menuHelper($item['submenu']);
        }

        if (isset($item['route'])) {
            $item['link'] = $this->resolveRouteToLink($item);
        } elseif (isset($item['path'])) {
            $item = $this->resolvePathToContent($item);
        }

        return $item;
    }
568610
public function BeforeDelete($item)
    {
        $navPages = NavigationPage::Schema()->FetchByPage(false, $item);
        foreach ($navPages as $navPage)
        {
            $item = $navPage->GetItem();
            $tree = new TreeBuilder(new NavigationTreeProvider($item->GetNavigation()));
            $tree->Remove($item);
        }
    }
193681
public function accordion($items = array(), $options = array()) {
		$defaults = array(
			'class' => '', 'id' => str_replace('.', '', uniqid('accordion_', true)),
		);
		$options = Hash::merge($defaults, $options);
		$options = $this->addClass($options, 'panel-group');

		if (is_array($items)) {
			$html = '';
			foreach ($items as $itemHeading => $itemBody) {
				$html .= $this->accordionItem($itemHeading, $itemBody, array('accordionId' => $options['id']));
			}
		} else {
			$html= $items;
		}

		return $this->tag('div', $html, $options);
	}
326989
protected function parseTemplate(array $item) {
        /**
         * Check if a title has been assigned to the element
         */
        if (isset($item['title'])) {
            $this->htmlOptions['linkOptions']['title'] = $item['title'];
        }
        /**
         * Parse the template
         */
        $replace = Html::a(Html::img($item['src'], $this->htmlOptions['thumbnailOptions']), $item['href'], $this->htmlOptions['linkOptions']);
        $template = str_replace('{item}', $replace, $this->template);
        return $template;
    }
1276120
public function setItem(Item $item)
    {
        $this->childOf = $item->id;
        $this->_item = $item;
        
        return $this;
    }
597051
public function getItemHelper(array $item): ItemHelper
    {
        if ($this->level !== 1 && $item['type'] === 'folder') {
            return new HeaderItemHelper($item);
        } elseif ($this->level === 2 || ($this->level > 1 && $this->getPageType() === 'folder')) {
            return new DropdownItemHelper($item);
        } else {
            return new NavItemHelper($item);
        }
    }
761157
private function resolveRouteToLink(array $item)
    {
        $param = !empty($item['param']) ? $item['param'] : [];

        if (isset($item['add'])) {
            Deprecated::warn('Menu item property "add"', null, 'Use "#" under "param" instead.');

            $add = $item['add'];
            if (!empty($add) && $add[0] !== '?') {
                $add = '?' . $add;
            }

            parse_str(parse_url($add, PHP_URL_QUERY), $query);
            $param = array_merge($param, $query);
            $param['_fragment'] = parse_url($add, PHP_URL_FRAGMENT);
        }

        return $this->app['url_generator']->generate($item['route'], $param);
    }
328370
public function isAllowedDirectory($item)
    {
        return
            is_dir($item) &&
            !ends_with($item, DIRECTORY_SEPARATOR.'.') &&
            !ends_with($item, DIRECTORY_SEPARATOR.'..');
    }
363542
protected function filter(\SplFileInfo $item) : bool
    {
        $filename = $item->getFilename();

        if (!$this->includeHidden && $filename{0} == '.') {
            return false;
        }

        if ($this->includeNames) {
            if (!in_array($filename, $this->includeNames, true)) {
                return false;
            }
        }
        elseif ($this->excludeNames && in_array($filename, $this->excludeNames, true)) {
            return false;
        }

        if ($this->includeExtensions) {
            if (!$this->longExtensions) {
                if (!in_array($item->getExtension(), $this->includeExtensions, true)) {
                    return false;
                }
            } else {
                $matches = false;
                foreach ($this->includeExtensions as $ext) {
                    if (
                        ($pos = strpos($filename, '.' . $ext)) !== false
                        && $pos == strlen($filename) - strlen($ext) - 1
                    ) {
                        $matches = true;
                        break;
                    }
                }
                if (!$matches) {
                    return false;
                }
            }
        }
        elseif ($this->excludeExtensions) {
            if (!$this->longExtensions) {
                if (in_array($item->getExtension(), $this->excludeExtensions, true)) {
                    return false;
                }
            } else {
                foreach ($this->excludeExtensions as $ext) {
                    if (
                        ($pos = strpos($filename, '.' . $ext)) !== false
                        && $pos == strlen($filename) - strlen($ext) - 1
                    ) {
                        return false;
                    }
                }
            }
        }

        if ($this->includeParents || $this->excludeParents) {
            $parent_path = $item->getPathname();
            $parent_path = substr($parent_path, 0, -strlen($filename) - 1);
            if ($this->includeParents) {
                if ($parent_path === false) {
                    // No space for any parent path.
                    return false;
                }
                $matches = false;
                foreach ($this->includeParents as $name) {
                    if (
                        ($pos = strpos($parent_path, '/' . $name)) !== false
                        && $pos == strlen($parent_path) - strlen($name) - 1
                    ) {
                        $matches = true;
                        break;
                    }
                }
                if (!$matches) {
                    return false;
                }
            }
            elseif ($parent_path !== false) {
                foreach ($this->excludeParents as $name) {
                    if (
                        ($pos = strpos($parent_path, '/' . $name)) !== false
                        && $pos == strlen($parent_path) - strlen($name) - 1
                    ) {
                        return false;
                    }
                }
            }
        }

        if ($this->customFilter) {
            return call_user_func_array($this->customFilter, [$item]);
        }

        return true;
    }