public function getMainUser()
    {
        $currentUser = $this->getUser();

        if ($this->_mainUser === null && $currentUser->getIsGuest() === false) {
            $session = Yii::$app->getSession();
            if ($session->has('main_user')) {
                $mainUserId = $session->get('main_user');
                $mainIdentity = call_user_func([$currentUser->identityClass, 'findIdentity'], $mainUserId);
            } else {
                $mainIdentity = $currentUser->identity;
            }

            $mainUser = clone $currentUser;
            $mainUser->setIdentity($mainIdentity);
            $this->_mainUser = $mainUser;
        }

        return $this->_mainUser;
    }
public function getMainUser()
    {
        $currentUser = $this->getUser();

        if ($this->_mainUser === null && $currentUser->getIsGuest() === false) {
            $session = Yii::$app->getSession();
            if ($session->has('main_user')) {
                $mainUserId = $session->get('main_user');
                $mainIdentity = call_user_func([$currentUser->identityClass, 'findIdentity'], $mainUserId);
            } else {
                $mainIdentity = $currentUser->identity;
            }

            $mainUser = clone $currentUser;
            $mainUser->setIdentity($mainIdentity);
            $this->_mainUser = $mainUser;
        }

        return $this->_mainUser;
    }
public function getMainUser ( ) { $ currentUser = $ this -> getUser ( ) ; if ( $ this -> _mainUser === null && $ currentUser -> getIsGuest ( ) === false ) { $ session = Yii :: $ app -> getSession ( ) ; if ( $ session -> has ( 'main_user' ) ) { $ mainUserId = $ session -> get ( 'main_user' ) ; $ mainIdentity = call_user_func ( [ $ currentUser -> identityClass , 'findIdentity' ] , $ mainUserId ) ; } else { $ mainIdentity = $ currentUser -> identity ; } $ mainUser = clone $ currentUser ; $ mainUser -> setIdentity ( $ mainIdentity ) ; $ this -> _mainUser = $ mainUser ; } return $ this -> _mainUser ; }
Get main user
@return User
@throws \yii\base\InvalidConfigException
Get main user