数据记录
@return array
@throws \yii\base\InvalidConfigException
778431
public function actionRecord()
    {
        $wechat = $this->getWechat();
        $fans = $this->getFans();
        if (!$fans) { // 存储粉丝信息
            $fans = Yii::createObject(Fans::className());
            $fans->setAttributes([
                'wid' => $wechat->id,
                'open_id' => $this->message['FromUserName'],
                'status' => Fans::STATUS_SUBSCRIBED
            ]);
            if ($fans->save() && $wechat->status > Wechat::TYPE_SUBSCRIBE) { // 更新用户详细数据, 普通订阅号无权限获取
                $fans->updateUser();
            }
        } elseif ($fans->status != Fans::STATUS_SUBSCRIBED) { // 更新关注状态
            $fans->subscribe();
        }

//        $history = new MessageHistory();
//        $attributes = [
//            'wid' => $wechat->id,
//            'module' => $this->getModuleName($this->api->lastProcessController),
//        ];
    }
1299116
public function actionConfigInfo()
    {
        $this->outputInfo("dev config file: " . Yii::getAlias($this->configFile));
        
        $config = $this->readConfig();
        
        if (!$config) {
            return $this->outputError("Unable to open config file.");
        }
        
        foreach ($config as $key => $value) {
            $this->output("{$key} => ".VarDumper::dumpAsString($value));
        }
    }
775524
public function getUserData()
    {
        // Don't crash if not using yii\web\User
        if (!Yii::$app->has('user') || !isset(Yii::$app->user->id))
        {
            return null;
        }

        return [
            'id' => Yii::$app->user->id,
        ];
    }
270461
public function modules()
    {
        $cache = Yii::$app->cache;
        if (($modules = $cache->get(self::CACHE_MODULES_DATA)) === false) {
            $modules = [];

            $model = $this->moduleModelClass;
            foreach ($model::models() as $id => $model) {
                $class = ModuleHelper::getBaseNamespace($model) . '\Module';
                if (!ModuleHelper::isAddonModule($class)) { // 扩展模块必须继承BaseModule
                    continue;
                }
                $modules[$id] = [
                    'class' => $class,
                    'name' => $model['name'],
                ];
            }

            $cache->set(self::CACHE_MODULES_DATA, $modules, null, new TagDependency([
                'tags' => [ModuleModel::CACHE_MODULES_DATA_DEPENDENCY_TAG]
            ]));
        }
        return $modules;
    }
1276516
public function getConfigObject()
    {
        if (!isset($this->_configObject) && !empty($this->config)) {
            $configSettings = json_decode($this->config, true);
            if (isset($configSettings['class'])) {
                $this->_configObject = Yii::createObject($configSettings);
                $this->_configObject->model = $this;
            }
        }

        return $this->_configObject;
    }
231286
protected function fetchData()
    {
        if (empty($this->_items) && $this->type !== null) {
            $authItems = Yii::app()->authManager->getAuthItems($this->type);
            $this->setAuthItems($authItems);
        }

        return $this->_items;
    }
1077858
public function actionLoad()
    {
        if (!Yii::$app->request->isAjax) {
            return $this->redirect(['forum/index']);
        }

        $result = ['messages' => '', 'more' => 0];

        if (!Podium::getInstance()->user->isGuest) {
            $loggedId = User::loggedId();
            $id = Yii::$app->request->post('message');
            $message = Message::find()->where(['id' => $id])->limit(1)->one();
            if ($message && ($message->sender_id == $loggedId || $message->isMessageReceiver($loggedId))) {
                $stack = 0;
                $reply = clone $message;
                while ($reply->reply && $stack < 5) {
                    $result['more'] = 0;
                    if ($reply->reply->sender_id == $loggedId && $reply->reply->sender_status == Message::STATUS_DELETED) {
                        $reply = $reply->reply;
                        continue;
                    }
                    $result['messages'] .= $this->renderPartial('load', ['reply' => $reply]);
                    $reply = $reply->reply;
                    if ($reply) {
                        $result['more'] = $reply->id;
                    }
                    $stack++;
                }
            }
        }
        return Json::encode($result);
    }
113345
public function getArray()
    {
        $config = @include $this->location;
        if (!is_array($config)) {
            throw new \Exception('Config not found');
        }

        $this->config = $config;

        return $config;
    }
469123
public static function getConfig()
    {
        if (!is_object(self::$componentConfig)) {
            $config = [];

            // check if we have default config
            if (isset(self::$defaultConfig)) {
                $config = self::$defaultConfig;
            }
            self::$componentConfig = new ConfigObject($config);
        }

        return self::$componentConfig;
    }
618834
protected function requestData() : array
    {
        switch ($this->method) {
            case 'post':
                return Yii::$app->request->post();
            case 'get':
                return Yii::$app->request->getQueryParams();
            default:
                throw new InvalidConfigException('Request method is not defined');
        }
    }
416887
public function init()
    {
        if (empty($this->serviceUrl)) {
            throw new InvalidConfigException("service_url cannot be empty. Please configure.");
        }
        if (empty($this->apiKey)) {
            throw new InvalidConfigException("api_key cannot be empty. Please configure.");
        }
        if ($this->cache) {
            // If class was specified as name, try to instantiate on application
            if (is_string($this->cache) && Yii::$app->has($this->cache)) {
                $this->cache = Yii::$app->get($this->cache);
            } elseif (is_array($this->cache)) {
                $this->cache = Yii::createObject($this->cache);
            }
        } elseif ($this->cache !== false && isset(Yii::$app->cache)) {
            $this->cache = Yii::$app->cache;
        }
        $this->_client = new \yii\httpclient\Client([
            'baseUrl' => $this->serviceUrl,
            'requestConfig' => [
                'method' => 'POST',
                'data' => [
                    'ApiKey' => $this->apiKey
                ]
            ],
            'responseConfig' => [
                'format' => \yii\httpclient\Client::FORMAT_XML
            ]
        ]);

        if ($this->requestIp) {
            $validator = new IpValidator([
                'ipv6' => true,
                'ipv4' => true,
                'subnet' => false,
                'expandIPv6' => true
            ]);
            if ($validator->validate($this->requestIp)) {
                ArrayHelper::setValue($this->_client->requestConfig, 'options.bindto', $this->requestIp);
            }
        }

        $result = $this->checkApiKey();
        if (!is_array($result) || empty($result) || strpos($result[0], 'not accepted') !== false) {
            throw new InvalidConfigException(
                "Api Key seems to be invalid: {$result[0]}",
                Exception::E_API_INVALID_PARAMETER
            );
        }
    }
1290886
protected function getConfig(): array
    {
        $loader = null;
        if ($this->isCacheEnabled() === true) {
            $loader = $this->getLoader();
            $cached = $loader->load();
            if (empty($cached) === false) {
                return $cached;
            }
        }

        if ($this->isFrameworkEnabled() === true) {
            $this->addFrameworkConfigs();
        }

        $merged = [];
        $merger = $this->getMerger();
        foreach ($this->getConfigs() as $config) {
            $merged = $merger->merge(
                $merged,
                $config->load()
            );
        }

        foreach ($this->getGlobalConfig() as $global) {
            $merged = $merger->merge($merged, $global);
        }

        foreach ($this->getModuleConfig() as $module) {
            $merged = $merger->merge($merged, $module);
        }

        if ($this->isCacheEnabled() === true) {
            if ($loader instanceof CacheLoader) {
                $loader->save($merged);
            }
        }

        return $merged;
    }
40547
public function actionSupport()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;
        $source = $this->findModel(Yii::$app->request->post('model_id'));
        if ($source->isSupported(Yii::$app->user->getId())) {
            return ['status' => 'supported'];
        } else {
            $model = new ArticleSupport();
            $model->load(Yii::$app->request->post(), '');
            $model->model_id = $source->id;
            if ($model->save() === false && !$model->hasErrors()) {
                throw new ServerErrorHttpException('Failed to update the object for unknown reason.');
            }
            return ['status' => 'success'];
        }
    }
1023574
public function getUrl()
    {
        if ($this->url === null) {
            switch ($this->dataType) {
                case 'json':
                    $this->url = $this->urlJson;
                    break;
                case 'xml':
                    $this->url = $this->urlXml;
                    break;
                default:
                    throw new InvalidConfigException('“dataType”配置错误！');
            }
        }
        
        return $this->url;
    }
1252425
public function actionCreate()
    {
        Yii::$app->getResponse()->format = 'json';
        $routes = Yii::$app->getRequest()->post('route', '');
        $routes = preg_split('/\s*,\s*/', trim($routes), -1, PREG_SPLIT_NO_EMPTY);
        $this->saveNew($routes);
        Helper::invalidate();
        return $this->getRoutes();
    }
370238
public static function getConfig()
    {
        if (static::$config !== null) {
            return static::$config;
        }

        $configs = Registry::get('config');

        return static::$config = isset($configs['cookie']) ? $configs['cookie'] : [];
    }
926250
private function _getRoots()
    {
        $directories = [];

        if (is_string($this->module->root)) {
            $root = Yii::getAlias($this->module->root);
            if ($this->module->scanRootParentDirectory) {
                $root = dirname($root);
            }

            $directories[] = $root;
        } elseif (is_array($this->module->root)) {
            foreach ($this->module->root as $root) {
                $directories[] = Yii::getAlias($root);
            }
        } else {
            throw new InvalidConfigException('Invalid `root` option value!');
        }

        return $directories;
    }