router::set PHP Method

set() public method

public set ( $methods, $url, $callback = null )
    function set($methods, $url, $callback = null)
    {
        $has_methods = is_array($methods);
        $key = $has_methods ? $url : $methods;
        $key = '/' . trim($key, '/');
        self::$routes[$key] = array('methods' => $has_methods ? $methods : array('GET', 'POST', 'PUT', 'DELETE'), 'callback' => $has_methods ? $callback : $url);
    }

Usage Example

Example #1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $_SERVER['REQUEST_METHOD'] = 'GET';
     router::route('/blog/:arg', function ($arg) {
         echo 'Argument: ' . $arg;
     }, 'GET', 'blog');
     router::route('/blog/*', function () {
         echo 'CatchAll';
     });
     router::route('/blog/arg', function () {
         echo 'NoArg';
     });
     router::route('/test.php', function () {
         echo 'test.php';
     });
     router::route('/proiecs/aed[]te\\*', function () {
         echo '/proiecs/aed[]te\\*';
     });
     router::route('/proiecs/:ala/bala/:korhaz/:edit/:buha', function ($arg1, $arg2, $arg3) {
         echo 'proiecs ' . $arg1 . $arg2 . $arg3;
     }, 'GET', 'proiecs');
     router::route('/proiecs/asfv', function () {
         echo '/proiecs/asfv/';
     });
     router::route(' /infinity', function () {
         echo 'infinity';
     }, 'GET', 'infinity');
     router::route('/infinity/ourubors/ternary', function () {
         echo '/infinity/ourubors/ternary';
     }, 'GET', 'infinity2');
     router::set('BASE', 'framework');
 }
All Usage Examples Of router::set