public function negotiate()
    {
        $request = $this->request ?: Yii::getApp()->getRequest();
        $response = $this->response ?: Yii::getApp()->getResponse();
        if (!empty($this->formats)) {
            $this->negotiateContentType($request, $response);
        }
        if (!empty($this->languages)) {
            Yii::get('i18n')->setLocale($this->negotiateLanguage($request));
        }
    }