public function route(array $method, $uri, $callback, $options = [])
    {
        if (is_array($uri)) {
            foreach ($uri as $u) {
                $this->route($method, $u, $callback, $options);

            }
            return $this;
        }
        $options = array_merge(['ajaxOnly' => false, 'continue' => false], (array)$options);

        if ($uri != '/') {
            $uri = $this->removeDuplSlash($uri) . '/';
        }
        // Replace named uri param to regex pattern.
        $pattern = $this->namedParameters($uri);
        $this->currentUri = $pattern;

        if ($options['ajaxOnly'] == false || $options['ajaxOnly'] && $this->req->ajax) {
            // If matched before, skip this.
            if ($this->matched === false) {
                // Prepare.
                $pattern = $this->prepare(
                    str_replace(['/?', '/*'], [$this->pattern['/?'], $this->pattern['/*']], $this->removeDuplSlash($this->group . $pattern))
                );

                // If matched.
                $method = count($method) > 0 ? in_array($this->req->method, $method) : true;
                if ($method && $this->matched($pattern)) {
                    if ($this->isGroup) {
                        $this->prams = array_merge($this->pramsGroup, $this->prams);
                    }

                    $this->req->args = $this->bindArgs($this->prams, $this->matchedArgs);

                    $this->matchedPath = $this->currentUri;
                    $this->routeCallback[] = $callback;

                    if ($options['continue']) {
                        $this->matched = false;
                    }
                }
            }
        }
        $this->_as($this->removeParameters($this->trimSlash($uri)));
        return $this;
    }
public function route(array $method, $uri, $callback, $options = [])
    {
        if (is_array($uri)) {
            foreach ($uri as $u) {
                $this->route($method, $u, $callback, $options);

            }
            return $this;
        }
        $options = array_merge(['ajaxOnly' => false, 'continue' => false], (array)$options);

        if ($uri != '/') {
            $uri = $this->removeDuplSlash($uri) . '/';
        }
        // Replace named uri param to regex pattern.
        $pattern = $this->namedParameters($uri);
        $this->currentUri = $pattern;

        if ($options['ajaxOnly'] == false || $options['ajaxOnly'] && $this->req->ajax) {
            // If matched before, skip this.
            if ($this->matched === false) {
                // Prepare.
                $pattern = $this->prepare(
                    str_replace(['/?', '/*'], [$this->pattern['/?'], $this->pattern['/*']], $this->removeDuplSlash($this->group . $pattern))
                );

                // If matched.
                $method = count($method) > 0 ? in_array($this->req->method, $method) : true;
                if ($method && $this->matched($pattern)) {
                    if ($this->isGroup) {
                        $this->prams = array_merge($this->pramsGroup, $this->prams);
                    }

                    $this->req->args = $this->bindArgs($this->prams, $this->matchedArgs);

                    $this->matchedPath = $this->currentUri;
                    $this->routeCallback[] = $callback;

                    if ($options['continue']) {
                        $this->matched = false;
                    }
                }
            }
        }
        $this->_as($this->removeParameters($this->trimSlash($uri)));
        return $this;
    }
public function route ( array $ method , $ uri , $ callback , $ options = [ ] ) { if ( is_array ( $ uri ) ) { foreach ( $ uri as $ u ) { $ this -> route ( $ method , $ u , $ callback , $ options ) ; } return $ this ; } $ options = array_merge ( [ 'ajaxOnly' => false , 'continue' => false ] , ( array ) $ options ) ; if ( $ uri != '/' ) { $ uri = $ this -> removeDuplSlash ( $ uri ) . '/' ; } // Replace named uri param to regex pattern.
 $ pattern = $ this -> namedParameters ( $ uri ) ; $ this -> currentUri = $ pattern ; if ( $ options [ 'ajaxOnly' ] == false || $ options [ 'ajaxOnly' ] && $ this -> req -> ajax ) { // If matched before, skip this.
 if ( $ this -> matched === false ) { // Prepare.
 $ pattern = $ this -> prepare ( str_replace ( [ '/?' , '/*' ] , [ $ this -> pattern [ '/?' ] , $ this -> pattern [ '/*' ] ] , $ this -> removeDuplSlash ( $ this -> group . $ pattern ) ) ) ; // If matched.
 $ method = count ( $ method ) > 0 ? in_array ( $ this -> req -> method , $ method ) : true ; if ( $ method && $ this -> matched ( $ pattern ) ) { if ( $ this -> isGroup ) { $ this -> prams = array_merge ( $ this -> pramsGroup , $ this -> prams ) ; } $ this -> req -> args = $ this -> bindArgs ( $ this -> prams , $ this -> matchedArgs ) ; $ this -> matchedPath = $ this -> currentUri ; $ this -> routeCallback [ ] = $ callback ; if ( $ options [ 'continue' ] ) { $ this -> matched = false ; } } } } $ this -> _as ( $ this -> removeParameters ( $ this -> trimSlash ( $ uri ) ) ) ; return $ this ; }
Register a route with callback.

@param array $method
@param string|array $uri
@param callable $callback
@param array $options

@return $this
Register a route with callback .