Add better uri creation from current

This commit is contained in:
Dennis Eichhorn 2019-03-09 19:33:25 +01:00
parent 632ce1c4dc
commit 89c14a69b8
2 changed files with 14 additions and 2 deletions

View File

@ -108,7 +108,7 @@ final class Request extends RequestAbstract
*/ */
private function initCurrentRequest() : void private function initCurrentRequest() : void
{ {
$this->uri = new Http(Http::getCurrent()); $this->uri = Http::fromCurrent();
$this->data = $_GET ?? []; $this->data = $_GET ?? [];
$this->files = $_FILES ?? []; $this->files = $_FILES ?? [];
$this->header->getL11n()->setLanguage($this->loadRequestLanguage()); $this->header->getL11n()->setLanguage($this->loadRequestLanguage());

View File

@ -193,6 +193,18 @@ final class Http implements UriInterface
. '://' . ($_SERVER['HTTP_HOST'] ?? ''). ($_SERVER['REQUEST_URI'] ?? ''); . '://' . ($_SERVER['HTTP_HOST'] ?? ''). ($_SERVER['REQUEST_URI'] ?? '');
} }
/**
* Create uri from current url
*
* @return Http Returns the current uri
*
* @since 1.0.0
*/
public static function fromCurrent() : self
{
return new self(self::getCurrent());
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -250,7 +262,7 @@ final class Http implements UriInterface
return ''; return '';
} }
return \array_slice($host, 0, $length); return \implode('.', \array_slice($host, 0, $length));
} }
/** /**