/** * Init request * * This is used in order to either initialize the current http request or a batch of GET requests * * @param string $uri URL * * @since 1.0.0 * @author Dennis Eichhorn <*****@*****.**> */ public function init($uri = null) { if ($uri === null) { $this->data = isset($_GET) ? $_GET : []; if (isset($_SERVER['CONTENT_TYPE'])) { if ($_SERVER['CONTENT_TYPE'] === 'application/json') { $this->data += json_decode(file_get_contents('php://input'), true); } elseif ($_SERVER['CONTENT_TYPE'] === 'application/x-www-form-urlencoded') { parse_str(file_get_contents('php://input'), $temp); $this->data += $temp; } } $this->uri->set(\phpOMS\Uri\Http::getCurrent()); } else { $this->setMethod($uri['type']); // TODO: is this correct? $this->uri->set($uri['uri']); } $this->path = explode('/', $this->uri->getPath()); $this->requestDestination = isset($this->path[1]) ? $this->path[1] : ''; $this->language = $this->path[0]; $this->hash = []; \phpOMS\Uri\UriFactory::setQuery('/scheme', $this->uri->getScheme()); \phpOMS\Uri\UriFactory::setQuery('/host', $this->uri->getHost()); \phpOMS\Uri\UriFactory::setQuery('/lang', $this->language); foreach ($this->path as $key => $path) { $paths = []; for ($i = 1; $i < $key + 1; $i++) { $paths[] = $this->path[$i]; } $this->hash[] = $this->hashRequest($paths); } }