Exemplo n.º 1
2
 /**
  * @param IUrl $destination
  */
 public function setDestination(IUrl $destination)
 {
     $this->destination = $destination;
     $this->getHeaders()->set('location', $destination->toString());
 }
Exemplo n.º 2
1
 /**
  * @param IUrl $url
  * @param array $subdomains
  *
  * @return bool
  */
 public function compareUrlToSubdomains(IUrl $url, array $subdomains)
 {
     if (count($subdomains) == 0) {
         return true;
     }
     return array_contains($subdomains, $url->getSubdomain());
 }
Exemplo n.º 3
0
Arquivo: UrlTest.php Projeto: weew/url
 private function check_url(IUrl $url)
 {
     $this->assertEquals('http', $url->getProtocol());
     $this->assertEquals('name', $url->getUsername());
     $this->assertEquals('pass', $url->getPassword());
     $this->assertEquals('just.an.example.com', $url->getHost());
     $this->assertEquals('example', $url->getDomain());
     $this->assertEquals('com', $url->getTLD());
     $this->assertEquals('just.an', $url->getSubdomain());
     $this->assertEquals('80', $url->getPort());
     $this->assertEquals('/products', $url->getPath());
     $this->assertEquals('sku=1234', $url->getQuery()->toString());
     $this->assertEquals('price', $url->getFragment());
 }
Exemplo n.º 4
0
 /**
  * @param IRoute[] $routes
  * @param $method
  * @param IUrl $url
  *
  * @return IRoute|null
  */
 protected function matchRoute(array $routes, $method, IUrl $url)
 {
     foreach ($routes as $route) {
         if ($this->compareRouteToMethod($route, $method) && $this->getUrlMatcher()->match($route->getPath(), $url->getPath()) && $this->getRestrictionsMatcher()->match($url)) {
             $parameters = $this->getUrlMatcher()->parse($route->getPath(), $url->getPath());
             $route->setParameters($parameters->toArray());
             return $route;
         }
     }
     return null;
 }