示例#1
0
 /**
  * Dispatch a request
  *
  * @param Request $request
  * @return Response
  * @throws BadRequestException
  * @throws NotFoundException if if no action has been found
  */
 public function dispatch(Request $request) : Response
 {
     $URL = $request->url();
     $routes = $this->_getRoutes();
     $app = AppRegistry::getInstance()->find($request->host());
     $this->_request = $request;
     $appName = $app->name();
     if (isset($this->_appScopes[$appName])) {
         $routes = array_merge($routes, $this->_appScopes[$appName]->_getRoutes());
     }
     $method = $_SERVER['REQUEST_METHOD'];
     foreach ($routes as $route) {
         if ($route->method() == $method && $route->parse($URL)) {
             return $route->exec($request);
         }
     }
     throw new NotFoundException();
 }
示例#2
0
<?php

use CoreTyson\Core\AppRegistry;
$appRegistry = AppRegistry::getInstance();
$appRegistry->set("Main", "www");
示例#3
0
 public function app()
 {
     return AppRegistry::getInstance()->get($this->_app);
 }