コード例 #1
0
ファイル: Router.php プロジェクト: hecrj/sea_core
 public function addRoutes($subdomain, RouteCollectionInterface $routes)
 {
     $this->routes[$subdomain] = $routes;
     $moduleName = $routes->getModuleName();
     if ($moduleName !== null) {
         $this->modules[$moduleName] = $subdomain;
     }
     return $this;
 }
コード例 #2
0
ファイル: MatchResolver.php プロジェクト: hecrj/sea_core
 public function getContext(RequestInterface $request, RouteCollectionInterface $routes)
 {
     if ($routes->isEmpty()) {
         return null;
     }
     $path = $request->getPath();
     foreach ($routes->getRoutes() as $routeName => $route) {
         $compiled = $this->compiler->compile($route);
         if (!preg_match($compiled->getRegexp(), $path, $matches)) {
             continue;
         }
         list($controllerName, $actionName) = explode('#', $route->getController(), 2);
         $arguments = $this->mergeArguments($matches, $compiled);
         $contextClass = $this->contextClass;
         return new $contextClass($controllerName, $actionName, $arguments, $routes->getModuleName(), $routeName);
     }
     return null;
 }
コード例 #3
0
ファイル: ExtractResolver.php プロジェクト: hecrj/sea_core
 public function getContext(RequestInterface $request, RouteCollectionInterface $routes)
 {
     $path = $request->getPath();
     if ($path == '/index') {
         $request->redirectTo('/');
     }
     $arguments = explode('/', substr($path, 1));
     $controller = array_shift($arguments);
     $controllerName = $controller ? ucfirst($controller) : 'Index';
     $actionName = array_shift($arguments);
     if ($actionName == 'index') {
         $request->redirectTo("/{$controller}");
     }
     if (empty($actionName)) {
         $actionName = 'index';
     }
     $contextClass = $this->contextClass;
     return new $contextClass($controllerName, $actionName, $arguments, $routes->getModuleName());
 }