flight\net\Router::map PHP Method

map() public method

Maps a URL pattern to a callback function.
public map ( string $pattern, callback $callback, boolean $pass_route = false )
$pattern string URL pattern to match
$callback callback Callback function
$pass_route boolean Pass the matching route object to the callback
    public function map($pattern, $callback, $pass_route = false)
    {
        $url = $pattern;
        $methods = array('*');
        if (strpos($pattern, ' ') !== false) {
            list($method, $url) = explode(' ', trim($pattern), 2);
            $methods = explode('|', $method);
        }
        $this->routes[] = new Route($url, $callback, $methods, $pass_route);
    }

Usage Example

Example #1
0
 function testCaseSensitivity()
 {
     $this->router->map('/hello', array($this, 'ok'));
     $this->request->url = '/HELLO';
     $this->router->case_sensitive = true;
     $this->check('404');
 }
All Usage Examples Of flight\net\Router::map