public function dispatch($path, RouteRequest $request = null)
    {
        if ($route = $this->match($path)) {
            // When the callback is an integer, it's refereing to a submux object.
            if (is_integer($route[2])) {
                $submux = $this->submux[$route[2]];
                $options = $route[3];

                // sub-path and call submux to dispatch
                // for pcre pattern?
                if ($route[0]) {

                    $matchedString = $route[3]['vars'][0];

                    return $submux->dispatch(substr($path, strlen($matchedString)));

                } else {
                    $s = substr($path, strlen($route[1]));

                    return $submux->dispatch(
                        substr($path, strlen($route[1])) ?: ''
                    );
                }
            }

            return $route;
        }
    }
public function dispatch($path, RouteRequest $request = null)
    {
        if ($route = $this->match($path)) {
            // When the callback is an integer, it's refereing to a submux object.
            if (is_integer($route[2])) {
                $submux = $this->submux[$route[2]];
                $options = $route[3];

                // sub-path and call submux to dispatch
                // for pcre pattern?
                if ($route[0]) {

                    $matchedString = $route[3]['vars'][0];

                    return $submux->dispatch(substr($path, strlen($matchedString)));

                } else {
                    $s = substr($path, strlen($route[1]));

                    return $submux->dispatch(
                        substr($path, strlen($route[1])) ?: ''
                    );
                }
            }

            return $route;
        }
    }
public function dispatch ( $ path , RouteRequest $ request = null ) { if ( $ route = $ this -> match ( $ path ) ) { // When the callback is an integer, it's refereing to a submux object. if ( is_integer ( $ route [ 2 ] ) ) { $ submux = $ this -> submux [ $ route [ 2 ] ] ; $ options = $ route [ 3 ] ; // sub-path and call submux to dispatch // for pcre pattern? if ( $ route [ 0 ] ) { $ matchedString = $ route [ 3 ] [ 'vars' ] [ 0 ] ; return $ submux -> dispatch ( substr ( $ path , strlen ( $ matchedString ) ) ) ; } else { $ s = substr ( $ path , strlen ( $ route [ 1 ] ) ) ; return $ submux -> dispatch ( substr ( $ path , strlen ( $ route [ 1 ] ) ) ? : '' ) ; } } return $ route ; } }
Match route in the current Mux and submuxes recursively.

The RouteRequest object is used for serving request method, host name
and other route information.

@param string $path
@param Pux\RouteRequest $request

@return array
Match route in the current Mux and submuxes recursively .