public function getIsConsoleRequest()
    {
        if ($this->_isConsoleRequest === null && \Yii::$app !== null) {
            if (\Yii::$app->getRequest() instanceof ConsoleRequest) {
                $this->_isConsoleRequest = true;
            } elseif (\Yii::$app->getRequest() instanceof WebRequest) {
                $this->_isConsoleRequest = false;
            }
        }
        if ($this->_isConsoleRequest === null) {
            throw new InvalidConfigException('Unable to determine if the application is a console or web application.');
        }

        return $this->_isConsoleRequest;
    }