コード例 #1
0
ファイル: Dispatcher.php プロジェクト: creogen/rapidphp
 protected function validateModule($module)
 {
     if ($this->application->hasModule($module)) {
         return true;
     }
     throw new \Rapid\Dispatcher\Exception('Module not found');
 }
コード例 #2
0
ファイル: Router.php プロジェクト: creogen/rapidphp
 protected function processPath()
 {
     $path = $this->request->path();
     $parts = explode('/', $path);
     $partsCount = count($parts);
     $partsMaxIndex = $partsCount - 1;
     $module = '';
     $controller = '';
     $action = '';
     $paramsKey = '';
     foreach ($parts as $key => $part) {
         if (!$controller && $this->application->hasModule($module . $part . '/')) {
             $module .= $part . '/';
             continue;
         }
         if (!$controller) {
             $controller = $part;
             continue;
         }
         if (!$action) {
             $action = $part;
             continue;
         }
         if ($partsMaxIndex > $key && !$paramsKey) {
             $paramsKey = $part;
             continue;
         }
         if ($paramsKey) {
             $this->request->setParam($paramsKey, $part);
             $paramsKey = '';
         } else {
             $this->request->setParam($part, 1);
         }
     }
     $this->request->setModule($module)->setController($controller ? $controller : $this->defaultController)->setAction($action ? $action : $this->defaultAction);
 }