示例#1
0
 /**
  * This method updates the current URL with the given string (useful create full
  * qualified URL from relative URL).
  *
  * @param string $url
  */
 public function updateUrl($urlString)
 {
     $url = new Customweb_Http_Url($urlString);
     // some fields shuld only be updated, in case it is a full qualified URL
     if (strstr($urlString, '://')) {
         if ($url->getHost() !== NULL) {
             $this->setHost($url->getHost());
         }
         if ($url->getPort() !== NULL) {
             $this->setPort($url->getPort());
         }
         if ($url->getPass() !== NULL) {
             $this->setPass($url->getPass());
         }
         if ($url->getScheme() !== NULL) {
             $this->setScheme($url->getScheme());
         }
         if ($url->getUser() !== NULL) {
             $this->setUser($url->getUser());
         }
     }
     if ($url->getFragment() !== NULL) {
         $this->setFragment($url->getFragment());
     }
     if ($url->getPath() !== NULL) {
         $this->setPath($url->getPath());
     }
     if ($url->getQuery() !== NULL) {
         $this->setQuery($url->getQuery());
     }
 }
示例#2
0
 /**
  * Constructor. Builds the URL from the given URL.
  *
  * @param string|Customweb_Http_Url $url
  * @throws InvalidArgumentException
  * @return Customweb_Http_Url
  */
 public function __construct($url = null)
 {
     if ($url instanceof Customweb_Http_Url || $url instanceof Customweb_Core_Url) {
         $this->setScheme($url->getScheme());
         $this->setPort($url->getPort());
         $this->setHost($url->getHost());
         $this->setUser($url->getUser());
         $this->setPass($url->getPass());
         $this->setPath($url->getPath());
         $this->setQuery($url->getQuery());
         $this->setFragment($url->getFragment());
     } else {
         if (is_string($url)) {
             $this->setUrlFromString($url);
         }
     }
     return $this;
 }