Example #1
0
 public static function route_resolve($value)
 {
     switch ($value[0]) {
         // route interface
         case 'api':
             if (!empty($value[2]) && !in_array(strtoupper($_SERVER['REQUEST_METHOD']), $value[2])) {
                 throw new Exception('api method not found');
             }
             self::$route_map['controller'] = $value[1];
             self::$route_map['action'] = strtolower($_SERVER['REQUEST_METHOD']);
             self::interface_route();
             exit;
             // route template
         // route template
         case 'tpl':
             template::view($value[2], $value[1]);
             exit;
             // route static
         // route static
         case 'html':
             include TEMPLATE_PATH . '/' . $value[1] . TEMPLATE_SUFFIX;
             exit;
             // route default
         // route default
         case 'url':
             $temp = explode('/', $value[1]);
             $count = count($temp);
             if (isset(static::$route_map['action'])) {
                 self::$route_map['controller'] = $temp[$count - 1];
                 $count > 1 && (self::$route_map['group'] = $temp[$count - 2]);
             } else {
                 self::$route_map['action'] = $temp[$count - 1];
                 $count > 1 && (self::$route_map['controller'] = $temp[$count - 2]);
                 $count > 2 && (self::$route_map['group'] = $temp[$count - 3]);
             }
             break;
             // route error
         // route error
         default:
             throw new Exception('route error');
     }
     !empty(self::$route_map['group']) && define('GROUP_NAME', self::$route_map['group']);
     !empty(self::$route_map['controller']) && define('CONTROLLER_NAME', self::$route_map['controller']);
     !empty(self::$route_map['action']) && define('ACTION_NAME', self::$route_map['action']);
     self::default_route();
 }
Example #2
0
 public function test()
 {
     template::view();
 }