/** * @param string|Uri $name * @param string|Uri $referer * * @return ScriptInfo */ public function resolveScript($name, $referer = null) { $path = Uri::cast($name); $status = $this->checkUrl($path); $info = new ScriptInfo($status); // if ($status != 0) { $info->setError($this->errorRecord(2, "Script reference error", ['script' => $name])); } else { $filter = $this->getPathFilter(); $path->complete($referer); $info->setPath($path); $file = (string) $this->fullPath($path); if ($filter) { $file = $filter($file, $path, $this); } $info->setFile($file); // Create the (unique) file key $key = $this->statScript($info); if (!$key) { $info->setError($this->errorRecord(1, "Script not found", ['file' => $file])); } $info->setKey($key); } return $info; }
/** * @param Destination $destination * @param Uri $context * @return Uri */ public function assemble(Destination $destination, $context = null) { $base = Uri::cast($context); $params = $destination->getParams(); $path = $this->resolvePattern($params->core()); $uri = new Uri(); $uri->setPath($base->getPath() . $path); return $uri; }
/** * @param Destination $destination * @param Uri $context */ public function assemble(Destination $destination, $context = null) { $base = Uri::cast($context); $model = clone $destination->getParams(); $model->set('~', $base->getPath()); $path = $model->render($this->getTemplate()); $uri = new Uri(); $uri->setPath($path); return $uri; }
/** * @param string|Uri $path * @return static */ public function setPath($path) { $this->path = Uri::cast($path); return $this; }
/** * @param string|Uri $base * @return self */ public function setBase($base = null) { $this->base = $base === null ? null : Uri::cast($base); return $this; }
/** * @param string|Uri $uri * @return Rakorium\Okapi */ public function setUri($uri) { $this->uri = Uri::cast($uri); // Auto-set "Host" header $host = $this->uri->getHost(); if ($host && version_compare($this->getVersion(), "1.0", ">=")) { $port = $this->uri->getPort(); if ($port) { $host .= ":{$port}"; } $this->getHeaders()->set("Host", $host); } // Auto-set the parameters $query = $this->uri->getQuery(); if ($query && strtoupper($this->getMethod()) == 'GET') { $this->setParams($this->parseParams($query)); } return $this; }