public function getIsAdmin()
    {
        if ($this->_isAdmin === null) {
            if ($this->getIsConsoleRequest() && !$this->forceWebRequest && !Yii::$app->hasModule('admin')) {
                $this->_isAdmin = false;
            } else {
                // if there is only an application with admin module and set as default route
                // this might by the admin module even when pathInfo is empty
                if (Yii::$app->defaultRoute == 'admin' && empty($this->pathInfo)) {
                    $this->_isAdmin = true;
                } else {
                    $resolver = Yii::$app->composition->getResolvedPathInfo($this);
                    $parts = explode('/', $resolver->resolvedPath);
                    $first = reset($parts);
                    if (preg_match('/admin/i', $first, $results)) {
                        $this->_isAdmin = true;
                    } else {
                        $this->_isAdmin = false;
                    }
                }
            }
        }
        
        return $this->_isAdmin;
    }
public function getIsAdmin()
    {
        if ($this->_isAdmin === null) {
            if ($this->getIsConsoleRequest() && !$this->forceWebRequest && !Yii::$app->hasModule('admin')) {
                $this->_isAdmin = false;
            } else {
                // if there is only an application with admin module and set as default route
                // this might by the admin module even when pathInfo is empty
                if (Yii::$app->defaultRoute == 'admin' && empty($this->pathInfo)) {
                    $this->_isAdmin = true;
                } else {
                    $resolver = Yii::$app->composition->getResolvedPathInfo($this);
                    $parts = explode('/', $resolver->resolvedPath);
                    $first = reset($parts);
                    if (preg_match('/admin/i', $first, $results)) {
                        $this->_isAdmin = true;
                    } else {
                        $this->_isAdmin = false;
                    }
                }
            }
        }
        
        return $this->_isAdmin;
    }
public function getIsAdmin ( ) { if ( $ this -> _isAdmin === null ) { if ( $ this -> getIsConsoleRequest ( ) && ! $ this -> forceWebRequest && ! Yii :: $ app -> hasModule ( 'admin' ) ) { $ this -> _isAdmin = false ; } else { // if there is only an application with admin module and set as default route // this might by the admin module even when pathInfo is empty if ( Yii :: $ app -> defaultRoute == 'admin' && empty ( $ this -> pathInfo ) ) { $ this -> _isAdmin = true ; } else { $ resolver = Yii :: $ app -> composition -> getResolvedPathInfo ( $ this ) ; $ parts = explode ( '/' , $ resolver -> resolvedPath ) ; $ first = reset ( $ parts ) ; if ( preg_match ( '/admin/i' , $ first , $ results ) ) { $ this -> _isAdmin = true ; } else { $ this -> _isAdmin = false ; } } } } return $ this -> _isAdmin ; }
Getter method resolves the current url request and check if admin context.

This is mostly used in order to bootstrap more modules and application logic in admin context.

@return boolean If the current request is in admin context return value is true, otherwise false.
Getter method resolves the current url request and check if admin context .