private function resolveCurrent()
    {
        $requestPath = $this->request->get('path', null);

        if (empty($requestPath)) {
            $home = $this->getHome();
            if (!$home) {
                throw new NotFoundHttpException('Home item could not be found, have you forget to set a default page?');
            }
            $requestPath = $home->alias;
        }

        $requestPath = rtrim($requestPath, '/');
        
        $urlParts = explode('/', $requestPath);
        
        $item = $this->aliasMatch($urlParts);

        if (!$item) {
            while (array_pop($urlParts)) {
                if (($item = $this->aliasMatch($urlParts, true)) !== false) {
                    break;
                }
            }
        }

        if ($item) {
            $this->_currentAppendix = substr($requestPath, strlen($item->alias) + 1);
            return $item;
        }

        // no item could have been resolved, but the home side type is module, which can have links.
        if (!$item && $this->home->type == 2) {
            $this->_currentAppendix = $requestPath;
            return $this->getHome();
        }
        
        // we could not resolve a page, check if the website has customized 404 error page defined.
        $navId = Config::get(Config::HTTP_EXCEPTION_NAV_ID, 0);
        $menu = Yii::$app->menu->find()->with(['hidden'])->where(['nav_id' => $navId])->one();
        if ($menu) {
            $menu->is404Page = true;
            return $menu;
        }

        throw new NotFoundHttpException("Unable to resolve requested path '".$requestPath."'.");
    }
private function resolveCurrent()
    {
        $requestPath = $this->request->get('path', null);

        if (empty($requestPath)) {
            $home = $this->getHome();
            if (!$home) {
                throw new NotFoundHttpException('Home item could not be found, have you forget to set a default page?');
            }
            $requestPath = $home->alias;
        }

        $requestPath = rtrim($requestPath, '/');
        
        $urlParts = explode('/', $requestPath);
        
        $item = $this->aliasMatch($urlParts);

        if (!$item) {
            while (array_pop($urlParts)) {
                if (($item = $this->aliasMatch($urlParts, true)) !== false) {
                    break;
                }
            }
        }

        if ($item) {
            $this->_currentAppendix = substr($requestPath, strlen($item->alias) + 1);
            return $item;
        }

        // no item could have been resolved, but the home side type is module, which can have links.
        if (!$item && $this->home->type == 2) {
            $this->_currentAppendix = $requestPath;
            return $this->getHome();
        }
        
        // we could not resolve a page, check if the website has customized 404 error page defined.
        $navId = Config::get(Config::HTTP_EXCEPTION_NAV_ID, 0);
        $menu = Yii::$app->menu->find()->with(['hidden'])->where(['nav_id' => $navId])->one();
        if ($menu) {
            $menu->is404Page = true;
            return $menu;
        }

        throw new NotFoundHttpException("Unable to resolve requested path '".$requestPath."'.");
    }
private function resolveCurrent ( ) { $ requestPath = $ this -> request -> get ( 'path' , null ) ; if ( empty ( $ requestPath ) ) { $ home = $ this -> getHome ( ) ; if ( ! $ home ) { throw new NotFoundHttpException ( 'Home item could not be found, have you forget to set a default page?' ) ; } $ requestPath = $ home -> alias ; } $ requestPath = rtrim ( $ requestPath , '/' ) ; $ urlParts = explode ( '/' , $ requestPath ) ; $ item = $ this -> aliasMatch ( $ urlParts ) ; if ( ! $ item ) { while ( array_pop ( $ urlParts ) ) { if ( ( $ item = $ this -> aliasMatch ( $ urlParts , true ) ) !== false ) { break ; } } } if ( $ item ) { $ this -> _currentAppendix = substr ( $ requestPath , strlen ( $ item -> alias ) + 1 ) ; return $ item ; } // no item could have been resolved, but the home side type is module, which can have links. if ( ! $ item && $ this -> home -> type == 2 ) { $ this -> _currentAppendix = $ requestPath ; return $ this -> getHome ( ) ; } // we could not resolve a page, check if the website has customized 404 error page defined. $ navId = Config :: get ( Config :: HTTP_EXCEPTION_NAV_ID , 0 ) ; $ menu = Yii :: $ app -> menu -> find ( ) -> with ( [ 'hidden' ] ) -> where ( [ 'nav_id' => $ navId ] ) -> one ( ) ; if ( $ menu ) { $ menu -> is404Page = true ; return $ menu ; } throw new NotFoundHttpException ( "Unable to resolve requested path '" . $ requestPath . "'." ) ; }
Find the current element based on the request get property 'path'.

1. if request path is empty us the getHome() to return alias.
2. find menu item based on the end of the current path (via array_pop)
3. if no item could be found the home item will be returned
4. otherwise return the alias match from step 2.
@return Item
@throws NotFoundHttpException
Find the current element based on the request get property path .