public static function execute(array $route, array $environment = array(), array $response = array())
    {
        list($pcre, $pattern, $callbackArg, $options) = $route;

        $callback = self::callback($callbackArg);

        $environment['pux.route'] = $route;
        if (is_array($callback) && $callback[0] instanceof Controller) {
            $environment['pux.controller'] = $callback[0];
            $environment['pux.controller_action'] = $callback[1];
        }

        if ($callback instanceof Closure) {
            $return = $callback($environment, $response);
        } else if ($callback[0] instanceof \PHPSGI\App) {
            $return = $callback[0]->call($environment, $response);
        } else if (is_callable($callback)) {
            $return = call_user_func($callback, $environment, $response);
        } else {
            throw new \LogicException("Invalid callback type.");
        }

        // Response fix
        if (is_string($return)) {
            if (!isset($response[0])) {
                $response[0] = 200;
            }
            if (!isset($response[1])) {
                $response[1] = [];
            }
            if (!isset($response[2])) {
                $response[2] = $return;
            }
            return $response;
        }

        return $return;
    }
public static function execute(array $route, array $environment = array(), array $response = array())
    {
        list($pcre, $pattern, $callbackArg, $options) = $route;

        $callback = self::callback($callbackArg);

        $environment['pux.route'] = $route;
        if (is_array($callback) && $callback[0] instanceof Controller) {
            $environment['pux.controller'] = $callback[0];
            $environment['pux.controller_action'] = $callback[1];
        }

        if ($callback instanceof Closure) {
            $return = $callback($environment, $response);
        } else if ($callback[0] instanceof \PHPSGI\App) {
            $return = $callback[0]->call($environment, $response);
        } else if (is_callable($callback)) {
            $return = call_user_func($callback, $environment, $response);
        } else {
            throw new \LogicException("Invalid callback type.");
        }

        // Response fix
        if (is_string($return)) {
            if (!isset($response[0])) {
                $response[0] = 200;
            }
            if (!isset($response[1])) {
                $response[1] = [];
            }
            if (!isset($response[2])) {
                $response[2] = $return;
            }
            return $response;
        }

        return $return;
    }
public static function execute ( array $ route , array $ environment = array ( ) , array $ response = array ( ) ) { list ( $ pcre , $ pattern , $ callbackArg , $ options ) = $ route ; $ callback = self :: callback ( $ callbackArg ) ; $ environment [ 'pux.route' ] = $ route ; if ( is_array ( $ callback ) && $ callback [ 0 ] instanceof Controller ) { $ environment [ 'pux.controller' ] = $ callback [ 0 ] ; $ environment [ 'pux.controller_action' ] = $ callback [ 1 ] ; } if ( $ callback instanceof Closure ) { $ return = $ callback ( $ environment , $ response ) ; } else if ( $ callback [ 0 ] instanceof \ PHPSGI \ App ) { $ return = $ callback [ 0 ] -> call ( $ environment , $ response ) ; } else if ( is_callable ( $ callback ) ) { $ return = call_user_func ( $ callback , $ environment , $ response ) ; } else { throw new \ LogicException ( "Invalid callback type." ) ; } // Response fix if ( is_string ( $ return ) ) { if ( ! isset ( $ response [ 0 ] ) ) { $ response [ 0 ] = 200 ; } if ( ! isset ( $ response [ 1 ] ) ) { $ response [ 1 ] = [ ] ; } if ( ! isset ( $ response [ 2 ] ) ) { $ response [ 2 ] = $ return ; } return $ response ; } return $ return ; }
Execute the matched route.

This method currently do two things:

1. create the controller from the route arguments.
2. executet the controller method by the config defined in route arguments.

$route: {pcre flag}, {pattern}, {callback}, {options}

*callback*:

The callback argument can be an array that contains a class name and a method name to be called.
a closure object or a function name.

*options*:

'constructor_args': arguments for constructing controller object.

@return string the response
Execute the matched route .