/** * 初始化输出的语言种类 * @return void * @throws InvalidArgumentException 如果不是可支持的输出语种,抛出异常 */ protected function _initLanguageType() { // 验证配置中的当前输出语种是否合法 try { $languageType = trim(Cfg::getApp('language')); Ap::setLanguageType($languageType); } catch (ErrorException $e) { } if (!in_array(Ap::getLanguageType(), $this->_languageTypes)) { throw new InvalidArgumentException('BaseAction is unable to determine the language of the config.'); } // 从RGP中获取‘ol’的值(output language type),并验证是否合法 // 以RGP中指定的输出语种为主 $languageType = Ap::getRequest()->getTrim('ol'); if ($languageType !== '') { if (in_array($languageType, $this->_languageTypes)) { Ap::setLanguageType($languageType); } else { throw new InvalidArgumentException('BaseAction is unable to determine the language of the request.'); } } }