public function __construct($uri) { parent::__construct(); $this->uri = Uri::create($uri); if (!$this->uri->isAbsolute()) { FrameworkRuntimeError::create('Redirect URI must be absolute, "%s" is given', null, $this->uri->toString())->_throw(); } }
/** * @return $this */ public static function createFromGlobals() { $serverName = $_SERVER['SERVER_NAME']; $scheme = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http'; $uriString = $scheme . '://' . $serverName . $_SERVER['REQUEST_URI']; $request = new static(); $request->setServerName($serverName)->setPort($_SERVER['SERVER_PORT'])->setUserAgent($_SERVER['HTTP_USER_AGENT'])->setRemoteAddr($_SERVER['REMOTE_ADDR'])->setRemotePort($_SERVER['REMOTE_PORT'])->setMethod($_SERVER['REQUEST_METHOD'])->setUri(Uri::create($uriString))->setHttpReferer(@$_SERVER['HTTP_REFERER'])->setGetInput(Input::createFromArray($_GET))->setCookieInput(Input::createFromArray($_COOKIE))->setPostInput(Input::createFromArray($_POST)); return $request; }
/** * @return string */ public function getBaseUri() { return $this->requestUri->makeBaseUri()->toString(); }