Пример #1
0
 /**
  * @param Route $other
  */
 public function merge(Route $other)
 {
     $temp = preg_replace('/\\[\\/\\]$/', '/', $other->route);
     $hasSlash = false;
     if (strlen($temp) > 0) {
         $hasSlash = $temp[strlen($temp) - 1] == '/';
     }
     $this->route = $temp . ($hasSlash ? '' : '/') . $this->route;
     if ($other->default != null && $this->default != null) {
         $this->default->merge($other->default);
     } elseif ($other->default != null && $this->default == null) {
         $this->default = $other->default;
     }
     if ($this->controller == null) {
         $this->controller = $other->controller;
     }
     if ($this->http_accept != null && $other->http_accept != null) {
         $this->http_accept = array_merge($other->http_accept, $this->http_accept);
     } elseif ($this->http_accept == null && $other->http_accept != null) {
         $this->http_accept = $other->http_accept;
     }
     if ($this->constraints != null && $other->constraints != null) {
         $this->constraints = array_merge($other->constraints, $this->constraints);
     } elseif ($this->constraints == null && $other->constraints != null) {
         $this->constraints = $other->constraints;
     }
 }