Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 2
0
 /**
  * @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;
 }
Ejemplo n.º 3
0
 /**
  * @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;
 }
Ejemplo n.º 4
0
 /**
  * @param string|Uri $path
  * @return static
  */
 public function setPath($path)
 {
     $this->path = Uri::cast($path);
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * @param string|Uri $base
  * @return self
  */
 public function setBase($base = null)
 {
     $this->base = $base === null ? null : Uri::cast($base);
     return $this;
 }
Ejemplo n.º 6
0
 /**
  * @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;
 }