コード例 #1
0
ファイル: Router.php プロジェクト: falmar/Epsilon
 /**
  * Creates the route to according to the URI
  */
 public function route()
 {
     if (!isset($this->Route)) {
         $strRoute = $this->getRouteString();
         $Route = $this->getDefaultRouteMap();
         $Params = [];
         if (strlen($strRoute) >= 3) {
             if ($Rules = $this->getRules()) {
                 foreach ($Rules as $rKey => $rV) {
                     if (preg_match($this->getRuleRegex($rKey), $strRoute)) {
                         $Params = $this->getMapFromRule($rKey, $strRoute);
                         $strRoute = $rV;
                         break;
                     }
                 }
             }
             foreach ($this->getRouteMaps() as $Map) {
                 if (substr_count($Map, '/') === substr_count($strRoute, '/')) {
                     $Route = [$Map => $strRoute];
                 }
             }
         }
         $arMap = explode('/', Input::cleanVar(array_keys($Route)[0]));
         $arPath = explode('/', Input::cleanVar(array_values($Route)[0]));
         $cMap = count($arMap);
         for ($f = 0; $f < $cMap; $f++) {
             $this->Route[$arMap[$f]] = $arPath[$f];
         }
         foreach ($Params as $pKey => $pValue) {
             $this->Route[$pKey] = $pValue;
         }
         if (!$this->Route) {
             Factory::getLogger()->emergency('Can\'t Route Application exiting...');
         }
     }
 }