Ejemplo n.º 1
0
 /**
  * dispatch the router: check for all defined routes and call closures
  */
 public static function dispatch()
 {
     $uri = strtok($_SERVER["REQUEST_URI"], '?');
     $qs = parse_url($_SERVER["REQUEST_URI"], PHP_URL_QUERY);
     $method = $_SERVER['REQUEST_METHOD'];
     foreach (self::$routes as $name => $route) {
         $route = self::parsePattern($route);
         $matched = array();
         if ($route == '' || preg_match('#' . $route . '#', $uri, $matched) && (self::$methods[$name] == 'ANY' || self::$methods[$name] == $method)) {
             array_shift($matched);
             if (self::$qs[$name] != '' && preg_match('#' . self::$qs[$name] . '#', $qs, $qsmatched)) {
                 array_shift($qsmatched);
                 $matched = array_merge($matched, $qsmatched);
                 self::$catched[] = $name;
                 //call_user_func_array(self::$callbacks[$name], $matched);
                 BurpEvent::listen($name, self::$callbacks[$name]);
                 BurpEvent::queue($name, $matched);
             } elseif (self::$qs[$name] == '') {
                 self::$catched[] = $name;
                 //call_user_func_array(self::$callbacks[$name], $matched);
                 BurpEvent::listen($name, self::$callbacks[$name]);
                 BurpEvent::queue($name, $matched);
             }
         }
     }
     //call missing if needed
     if (!is_null(self::$missing_callback)) {
         $diff = array_diff(self::$tocatch, self::$catched);
         if (count($diff) >= count(self::$tocatch)) {
             call_user_func(self::$missing_callback);
             BurpEvent::listen('missing', self::$callbacks[$name]);
             BurpEvent::fire('missing');
         }
     }
     BurpEvent::flushAll();
 }
Ejemplo n.º 2
0
<?php

//dataform routing
Burp::post(null, 'process=1', array('as' => 'save', function () {
    BurpEvent::queue('dataform.save');
}));
//datagrid routing
Burp::get(null, 'page/(\\d+)', array('as' => 'page', function ($page) {
    BurpEvent::queue('dataset.page', array($page));
}));
Burp::get(null, 'ord=(-?)(\\w+)', array('as' => 'orderby', function ($direction, $field) {
    $direction = $direction == '-' ? "DESC" : "ASC";
    BurpEvent::queue('dataset.sort', array($direction, $field));
}))->remove('page');
//todo: dataedit
if (version_compare(app()->version(), '5.2') > 0) {
    Route::group(['middleware' => 'web'], function () {
        Route::get('rapyd-ajax/{hash}', array('as' => 'rapyd.remote', 'uses' => '\\Zofe\\Rapyd\\Controllers\\AjaxController@getRemote'));
        //Route::controller('rapyd-demo', '\Zofe\Rapyd\Demo\DemoController');
    });
} else {
    Route::get('rapyd-ajax/{hash}', array('as' => 'rapyd.remote', 'uses' => '\\Zofe\\Rapyd\\Controllers\\AjaxController@getRemote'));
    //Route::controller('rapyd-demo', '\Zofe\Rapyd\Demo\DemoController');
}
Ejemplo n.º 3
0
<?php

//dataform routing
Burp::post(null, 'process=1', ['as' => 'save', function () {
    BurpEvent::queue('dataform.save');
}]);
//datagrid routing
Burp::get(null, 'page/(\\d+)', ['as' => 'page', function ($page) {
    BurpEvent::queue('dataset.page', [$page]);
}]);
Burp::get(null, 'ord=(-?)(\\w+)', ['as' => 'orderby', function ($direction, $field) {
    $direction = $direction == '-' ? "DESC" : "ASC";
    BurpEvent::queue('dataset.sort', [$direction, $field]);
}])->remove('page');
Route::get('rapyd-ajax/{hash}', ['as' => 'rapyd.remote', 'uses' => '\\Zofe\\Rapyd\\Controllers\\AjaxController@getRemote']);