Example #1
0
 public function routeList()
 {
     $routes = Route::all();
     //array of all routes
     $routes_array = json_decode($routes, TRUE);
     //var_dump($routes_array); //correct
     $allMethods = array();
     foreach ($routes_array as $route) {
         //each route access
         //get route object
         $api = Route::find($route['id']);
         //echo $api."<br>"; //correct
         //get all methods of this route and push to allMethods array
         $routeMethods = $api->methods;
         //echo $routeMethods."<br>";
         foreach ($routeMethods as $routeMethod) {
             // echo $routeMethod."<br>";
             $method = $routeMethod->method;
             $description = $routeMethod->description;
             $routeMethod_array = array();
             $routeMethod_array['route'] = $route['name'];
             $routeMethod_array['method'] = $routeMethod->method;
             $routeMethod_array['tags'] = $routeMethod->tags;
             $routeMethod_array['method_id'] = $routeMethod->id;
             $routeMethod_array['description'] = $routeMethod->description;
             array_push($allMethods, $routeMethod_array);
             $routeMethod_array = NULL;
         }
     }
     //foreach
     return $allMethods;
 }
Example #2
0
 function display()
 {
     $this->view->assign('base_uri', BASE_URI);
     $this->view->assign('base_host', BASE_HOST);
     $this->view->assign('error_uri', Route::urlize('disconnect'));
     $r = new Route();
     $this->view->assign('current_page', $r->find());
     if (!isset($_SERVER['HTTP_MOD_REWRITE']) || !$_SERVER['HTTP_MOD_REWRITE']) {
         $this->view->assign('page_key_uri', '?q=');
     } else {
         $this->view->assign('page_key_uri', '');
     }
     $this->view->assign('secure_websocket', file_get_contents(CACHE_PATH . 'websocket'));
     // And we load some public values of the system configuration
     $cd = new \Modl\ConfigDAO();
     $config = $cd->get();
     $public_conf = array('bosh_url' => $config->boshurl, 'timezone' => $config->timezone);
     $this->view->assign('server_conf', json_encode($public_conf));
 }
Example #3
0
 private function dispatch(Request $request)
 {
     $match = \Route::find($request->domain() . $request->path());
     if (!$match) {
         // try to use fallback metcanism
         return false;
     }
     if (!$match->rule->isMethodAllowed($request)) {
         // return 405 Method Not Allowed
         return false;
     }
     if (!$match->rule->isSecurityPolicyMatched($request)) {
         // return 426 Upgrade Required (in fact, makes sense only from plain http -> tls switch)
         return false;
     }
     foreach ($match->rule->getBefore() as $callback) {
         $before_result = call_user_func(\Route::getFilter($callback), $request, $match);
         if ($before_result) {
             return $before_result;
         }
     }
     $action = $match->rule->getAction($request->method());
     $with = $match->rule->getWith();
     foreach ($match->matches as $name => $value) {
         $with[$name] = $value;
     }
     $callback = \resolve_callback($action, strtolower($request->method()));
     $result = call_user_func_array($callback, $with);
     foreach ($match->rule->getAfter() as $callback) {
         $after_result = call_user_func(\Route::getFilter($callback), $request, $result);
         if ($after_result) {
             return $after_result;
         }
     }
     return $result;
 }
 public function del_routes(Request $request)
 {
     $id = $request->input('id');
     $routes = Route::find($id);
     $routes->delete();
 }
Example #5
0
 public function handle()
 {
     $r = new \Route();
     $this->runRequest($r->find());
 }