static function instance()
 {
     if (self::$instance == null) {
         $config = new ConfigurationManager('config.xml');
         self::$instance = $config;
     }
     return self::$instance;
 }
Beispiel #2
0
 private static function executeHandlers()
 {
     $config = ConfigurationManager::instance();
     if ($handlers = $config->section('handlers')) {
         $uri = $_SERVER['REQUEST_URI'];
         foreach ($handlers as $handler) {
             $pattern = $handler->requestPattern();
             $route = new HandlerRoute($pattern);
             if ($route->match($uri) !== false) {
                 $handler->handleRequest();
                 break;
             }
         }
     }
 }
Beispiel #3
0
 function handleRequest()
 {
     $config = ConfigurationManager::instance();
     $uri = $_SERVER['REQUEST_URI'];
     if (list($route, $matches) = $config->routes->match($uri)) {
         if (!array_key_exists('controller', $route->args)) {
             echo 'No "controller" attribute specified for route.';
             print_r($route);
             exit;
         }
         if (!array_key_exists('action', $route->args)) {
             echo 'No "action" attribute specified for route.';
             print_r($route);
             exit;
         }
         $rd = new RouteDispatcher();
         $rd->dispatch($route, $matches);
     } else {
         header("HTTP/1.0 404 Not Found");
         header("Status: 404 Not Found");
         die('No match found');
     }
 }
Beispiel #4
0
 function __construct()
 {
     $this->config = ConfigurationManager::instance();
 }