Пример #1
0
 /**
  * Framework entry point
  *
  * @return void.
  */
 public function dispatch()
 {
     include_once 'action/controller/http/HTTPResponse.php';
     include_once 'action/controller/http/HTTPRequest.php';
     $request = new HTTPRequest();
     $response = new HTTPResponse();
     try {
         $configurator = $this->manager->getConfigurator();
         Registry::put($configurator, '__configurator');
         Registry::put($logger = new Logger($configurator), '__logger');
         $ap = $configurator->getApplicationPath();
         // application path
         $an = $configurator->getApplicationName();
         // application name
         $logger->debug('[Medick] >> version: ' . Medick::getVersion() . ' ready for ' . $an);
         $logger->debug('[Medick] >> Application path ' . $ap);
         $routes_path = $ap . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR . $an . '.routes.php';
         include_once $routes_path;
         // load routes
         $logger->debug('[Medick] >> Config File: ' . str_replace($ap, '${' . $an . '}', $configurator->getConfigFile()));
         $logger->debug('[Medick] >> Routes loaded from: ' . str_replace($ap, '${' . $an . '}', $routes_path));
         ActionControllerRouting::recognize($request)->process($request, $response)->dump();
     } catch (Exception $ex) {
         ActionController::process_with_exception($request, $response, $ex)->dump();
         $logger->warn($ex->getMessage());
     }
 }
Пример #2
0
 /**
 *  Dispatch a request from Apache
 *
 *  Called from file dispatch.php, which is invoked by
 *  {@link http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html Apache mod_rewrite}
 *  whenever a client makes a request.  Actions:
 *  <ol>
 *    <li>Remove forbidden tags and attributes from
 *      {@link http://www.php.net/reserved.variables#reserved.variables.get $_GET},
 *      {@link http://www.php.net/reserved.variables#reserved.variables.post $_POST} and
 *      {@link http://www.php.net/reserved.variables#reserved.variables.request $_REQUEST}.
 </li>
 *    <li>Start a session to keep track of state between requests from
 *      the client.</li>
 *    <li>Construct an ActionController to process the action.</li>
 *    <li>Process the route</li>
 *  </ol>
 *  @uses ActionController::__construct()
 *  @uses ActionController::process_route()
 *  @uses ActionController::process_with_exception()
 *  @uses InputFilter::process_all()
 *  @uses Session::start()
 */
 function dispatch()
 {
     if (TRAX_ENV != 'production') {
         $start = microtime(true);
     }
     try {
         InputFilter::process_all();
         Session::start();
         $ac = new ActionController();
         $ac->process_route();
     } catch (Exception $e) {
         ActionController::process_with_exception($e);
     }
     if (TRAX_ENV != 'production') {
         $duration = "(" . round((microtime(true) - $start) * 1000, 1) . "ms)";
         $url = parse_url($_SERVER['REQUEST_URI']);
         Trax::log("Rendered {$url['path']} {$duration}");
     }
 }