/** * Make route from object * @param ZRoute $a_route * @return ZRoute */ public function &fromObject($a_route) { $this->clear(); if ($a_route instanceof ZRoute) { $this->m_segments = $a_route->getSegments(); $this->m_query->setData($a_route->getQuery()); } return $this; }
/** * Make route from object * @param ZRoute $a_route * @return ZRoute */ public function &fromObject($a_route) { $this->clear(); if ($a_route instanceof ZRoute) { $this->m_path = clone $a_route->getPath(); $this->m_param = clone $a_route->getParams(); $this->m_query = clone $a_route->getQuery(); $this->m_mode = $a_route->getMode(); } return $this; }
/** * @return ZRouteMap */ public function routePath($a_path, ZRoute &$a_route = null, $a_throws = false) { $path = new ZRoutePath(); $p = new ZRoute($a_path); $route =& $a_route; if (!$route) { $route = new ZRoute(); } $t = $p->getSegment(0); $t = empty($t) ? self::DEFAULT_MODULE_NAME : $t; if ($this->getLoader()->hasModule($t)) { try { $route->setModule($t); $path->module =& $this->getLoader()->module($t); } catch (ZException $e) { if ($a_throws) { throw $e; } return $path; } return $path->module->routePath($p->pop_start(), $route, $a_throws); } else { $route->setModule($this->getName()); $path->module =& $this; } if (!$path->module) { return $path; } $t = $p->getSegment(0); $t = empty($t) ? self::DEFAULT_CONTROLLER_NAME : $t; $p->pop_start(); try { $route->setController($t); $path->controller =& $path->module->getLoader()->controller($t); } catch (ZException $e) { if ($a_throws) { throw $e; } return $path; } if (!$path->controller) { return $path; } $t = $p->getSegment(0); $t = empty($t) ? self::DEFAULT_ACTION_NAME : $t; $p->pop_start(); if ($path->controller->hasAction($t)) { $route->setAction($t); $path->action = $t; } else { if ($a_throws) { throw new ZException('Action ' . $t . ' not found at ' . $path->controller->getName() . ' controller in ' . $path->module->getName() . ' module', ZControllerException::EXC_ACTION); } return $path; } foreach ($p->getSegments() as $_p) { $route->push($_p); } $route->getQuery()->setData($p->getQuery()); unset($p); return $path; }