public function buildRedirectUri($redirect_uri, $authorization_code, $state = null) { $urlValidator = new \yii\validators\UrlValidator(); if (!$urlValidator->validate($redirect_uri)) { throw new \yii\base\InvalidParamException('Invalid Redirect Uri'); } $parsedUrl = parse_url($redirect_uri); if (isset($parsedUrl['query'])) { $redirect_uri .= "&code={$authorization_code}" . ($state === null ? "" : "&state={$state}"); } else { $redirect_uri . "?code={$authorization_code}" . ($state === null ? "" : "&state={$state}"); } return $redirect_uri; }
private function _validateParams() { // Email if (empty($this->email)) { throw new \yii\base\InvalidConfigException("`email` param is required"); } else { $validator = new \yii\validators\EmailValidator(); if (!$validator->validate($this->email, $error)) { throw new \yii\base\InvalidConfigException($error); } } // Size if (!empty($this->size)) { $validator = new \yii\validators\NumberValidator(["min" => 1, "max" => 2048]); if (!$validator->validate($this->size, $error)) { throw new \yii\base\InvalidConfigException($error); } } // Rating if (!empty($this->rating)) { $validator = new \yii\validators\RangeValidator(["range" => ["g", "pg", "r", "x"]]); if (!$validator->validate($this->rating, $error)) { throw new \yii\base\InvalidConfigException($error); } } // Default image if (!empty($this->defaultImage)) { $validator = new \yii\validators\UrlValidator(); if (!$validator->validate($this->defaultImage, $error)) { $validator = new \yii\validators\RangeValidator(["range" => ["404", "mm", "identicon", "monsterid", "wavatar", "retro", "blank"]]); if (!$validator->validate($this->defaultImage, $error)) { throw new \yii\base\InvalidConfigException($error); } } } }