This method is mainly provided for testing purpose.
public setPathInfo ( string $value ) | ||
$value | string | the path info of the current request |
/** * Parses the URL and sets the language accordingly * @param \yii\web\Request $request * @return array|bool */ public function parseRequest($request) { if ($this->enablePrettyUrl) { $pathInfo = $request->getPathInfo(); $language = explode('/', $pathInfo)[0]; $locale = ArrayHelper::getValue($this->aliases, $language, $language); if (in_array($language, $this->languages)) { $request->setPathInfo(substr_replace($pathInfo, '', 0, strlen($language) + 1)); Yii::$app->language = $locale; static::$currentLanguage = $language; } } else { $params = $request->getQueryParams(); $route = isset($params[$this->routeParam]) ? $params[$this->routeParam] : ''; if (is_array($route)) { $route = ''; } $language = explode('/', $route)[0]; $locale = ArrayHelper::getValue($this->aliases, $language, $language); if (in_array($language, $this->languages)) { $route = substr_replace($route, '', 0, strlen($language) + 1); $params[$this->routeParam] = $route; $request->setQueryParams($params); Yii::$app->language = $locale; static::$currentLanguage = $language; } } return parent::parseRequest($request); }