Exemplo n.º 1
0
 /**
  * @ignore
  */
 public function resolve($uPathInfo, $uMethod = null, $uMethodExt = null)
 {
     $this->load();
     // @todo use $this->routes->top() if needed.
     foreach ($this->rewrites as $tRewriteItem) {
         if (isset($tRewriteItem[2]) && $uMethod !== null && !in_array($uMethod, $tRewriteItem[2])) {
             continue;
         }
         if ($this->rewriteUrl($uPathInfo, $tRewriteItem['match'], $tRewriteItem['forward'])) {
             break;
         }
     }
     // @todo use $this->routes->top() if needed.
     foreach ($this->routes as $tRouteItem) {
         if (isset($tRouteItem[2]) && $uMethod !== null && !in_array($uMethod, $tRouteItem[2])) {
             continue;
         }
         $tMatches = Utils::pregMatch(ltrim($tRouteItem[0], '/'), $uPathInfo);
         if (count($tMatches) > 0) {
             $tParameters = array('method' => $uMethod, 'methodext' => $uMethodExt);
             foreach ($tRouteItem[3] as $tDefaultKey => $tDefaultItem) {
                 if (isset($tMatches[$tDefaultKey])) {
                     $tParameters[$tDefaultKey] = $tMatches[$tDefaultKey];
                 } else {
                     $tParameters[$tDefaultKey] = $tDefaultItem;
                 }
             }
             return array($uPathInfo, $tRouteItem[1], $tParameters);
         }
     }
     return array($uPathInfo, null, null);
 }