Dispatch a request to a given controller and method.

@param  \Nova\Routing\Route  $route
@param  mixed  $controller
@param  string  $method
@return mixed
341598
public function dispatch(Route $route, $controller, $method)
    {
        $parameters = $this->resolveClassMethodDependencies(
            $route->parametersWithoutNulls(), $controller, $method
        );

        if (method_exists($controller, 'callAction')) {
            return $controller->callAction($method, $parameters);
        }

        return call_user_func_array(array($controller, $method), $parameters);
    }
773422
private function extractFunctionFromRoute(Route $route)
    {
        $controller = explode('::', $this->extractControllerDefaultFromRoute($route));

        return isset($controller[1]) ? $controller[1] : null;
    }
106053
function get($route, callable $controller) {
		if ($this->request->requestMethod() == 'get') {
			$this->any($route, $controller);
		}
	}
1184164
public function dispatch(string $method, string $url): array
    {
        $route = $this->match($url);

        $result = [
            'method' => $method,
            'url' => $url,
        ];

        if (!$route) {
            $result['error'] = 404;
        } elseif (isset($route['methods'][$method])) {
            $params = $route['params'];
            $handler = $route['methods'][$method];

            if (!$handler instanceof \Closure) {
                if (isset($handler['params'])) {
                    $params += $handler['params'];
                }

                $handler = [
                    'app' => $handler['app'] ?? $params['app'] ?? null,
                    'controller' => $handler['controller'] ?? $params['controller'] ?? null,
                    'action' => $handler['action'] ?? $params['action'] ?? null,
                ];
            }

            $result += [
                'route' => $route['route'],
                'params' => $params,
                'handler' => $handler,
            ];
        } else {
            $result += [
                'error' => 405,
                'route' => $route['route'],
                'params' => $route['params'],
                'allowed' => \array_keys($route['methods']),
            ];
        }

        return $this->result = $result;
    }
1234339
public function addRoute(string $method, string $route, ...$callback)
    {
        $method = strtolower($method);
        $route = ltrim($route, '/');
        $group = rtrim($this->group, '/') . '/';
        $route = $group . $route;
        $scope = $this->middleware->count();
        $this->layer[$method][] = new Route(
            $method,
            $route,
            $callback,
            $scope,
            $this->group
        );

        return true;
    }
982827
public function dispatch(Request $request)
    {
        $pathInfo = $request->getPathInfo();
        $method   = $request->getMethod();

        $route = $this->collection->find($method, $pathInfo);

        if ( ! $route) {
            throw new \Exception('Route not found !');
        }

        return $this->dispatcher->dispatch($route);
    }
244722
public function fileController($route, $class, $method = "")
    {
        $file = "../OxApp/controllers/" . $class . "Controller.php";
        $file = str_replace("\\", "/", $file);
        if (is_readable($file) === false) {
            throw new \Exception($file . ' Controller Not Found');
        } else {
            $class .= "Controller";
            try {
                $this->useMethod($class, $method);
                Router::$route = $route;
                Router::$controller = $class;
                Router::$routeCounts += 1;
            } catch (\RuntimeException $e) {
                throw new \Exception($e);
            }
        }
    }
1204131
public function dispatch(Route $route)
    {
        do {
            $this->getEventManager()->publish("pre.dispatch", array($route, $this));

            $protoView = $this->_view->cloneThis();
            $controllerClassName = $route->getControllerName() . "Controller";
            $action = $route->getActionName() . "Action";
            $classPath = $this->getControllerPath() . DIRECTORY_SEPARATOR . $controllerClassName . ".php";
            $viewPath = $route->getControllerPath()
                . DIRECTORY_SEPARATOR
                . $route->getActionPath()
                . $protoView->getViewExt();

            if (!file_exists($classPath)) {
                // Use base controller
                $controllerClassName = 'Controller';
            } else {
                require_once $classPath;
            }

            $controller = new $controllerClassName($this);
            $controller->setRouter($this->getRouter());
            $controller->setRequest($this->getRequest());
            $controller->setParams(
                array_merge(
                    array(
                        "dispatcher" => $this,
                        "bootstrap" => $this->getBootstrap()
                    ),
                    $route->getParams()));
            $controller->setRawBody(@file_get_contents('php://input'));

            $controller->setView($protoView->cloneThis());
            $controller->view->controllerPath = $this->getControllerPath();

            if (method_exists($controller, $action)) {
                ob_start();
                $controller->init();
                $controller->$action();
                array_push($this->_viewsQueue, ob_get_contents());
                ob_end_clean();
            } else {
                if (!file_exists($controller->view->getViewPath() . DIRECTORY_SEPARATOR . $viewPath)) {
                    throw new RuntimeException("Page not found {$route->getControllerName()} -> {$route->getActionName()}", 404);
                }
            }

            if ($controller->view->getViewPath()) {
                array_push(
                    $this->_viewsQueue,
                    $controller->getView()->render(
                        (($controller->getViewPath() !== false) ? $controller->getViewPath() : $viewPath))
                );
            }

            $this->getEventManager()->publish("post.dispatch", array($this));
        } while(($route = array_shift($this->_actions)));

        return implode("", $this->_viewsQueue);
    }
405415
public function dispatch(callable $controller, array $vars = [], BaseRoute $route = null)
    {
        if ($group = $route->getParentGroup()) {
            $this->response = (new PipelineProcessor())
                ->handlePayload(new Payload($group, $this->request, $this->response))
                ->getResponse();
        }

        $this->response = (new PipelineProcessor())
            ->handlePayload(new Payload($route, $this->request, $this->response))
            ->getResponse();

        return \call_user_func_array(
            $controller,
            [$this->request, $this->response, $vars]
        );
    }
1230363
protected function callWithinStack( $instance, $route, $request, $method )
	{
		$middleware = HttpFactory::i()->isMiddlewareDisabled() ? [] : $this->getMiddleware( $instance, $method );

		// Here we will make a stack onion instance to execute this request in, which gives
		// us the ability to define middlewares on controllers. We will return the given
		// response back out so that "after" filters can be run after the middlewares.
		return ( new Pipeline() )->send( $request )->through( $middleware )->then( function ( $request ) use ( $instance, $route, $method )
		{
			return $this->router->prepareResponse( $request, $this->call( $instance, $route, $method ) );
		} );
	}
500755
public static function Route($route, $controller, $closure = null) {
        $route = strtolower($route);
        $controller = ucwords(strtolower($controller));
        $request = KernelHttp::request();
        if($request->getUrlApi() == $route)
            self::explorer($route, $controller, $closure, $request);
    }
832688
private function dispatch($request, $route)
    {
        if ($route->matched()) {
            $request = $request->withPathToMatch($route->matched(), $route->trailing());
        }
        // dispatch the route!
        return $this->dispatcher->withRoute($route)->__invoke($request);
    }
219793
protected function runController( Request $request )
	{
		list( $class, $method ) = explode( '@', $this->action['uses'] );

		return ( new ControllerDispatcher( $this->router, $this->bindings ) )->dispatch( $this, $request, $class, $method );
	}
311297
public function dispatchRoute(Parsed $route, array $parameters = [])
    {
        $handler = $route->getHandler();
        if (isset($handler['controler']) && isset($handler['action'])) {
            $routePlaceholders             = $route->getPlaceholders();
            list($controllerName, $action) = $this->resolveControlerAction(
                $route->getParameters(),
                $routePlaceholders,
                $handler
            );

            // Create instance of target class
            $controller = new $controllerName();
            // Create class method name with prefix
            $methodName = $this->actionName.$action;

            $parameterMap = $this->getMethodParameters(
                $controllerName,
                $methodName
            );

            $methodParameters = $this->getFunctionArgumentsControlers(
                $parameterMap,
                $route->getParameters(),
                $routePlaceholders,
                $handler
            );

            return call_user_func_array(
                [
                    $controller,
                    $methodName
                ],
                $methodParameters
            );
        }

        return $this->dispatchNotFound();
    }
1259863
public function dispatch($method = null, $path = null)
    {
        $match = $this->getMatch($method, $path);

        foreach ($match->before as $filter) {
            if (empty($filter)) {
                continue;
            }
            $response = $this->executeCallback($this->getFilterCallback($filter), $match->args, true);
            if (!is_null($response)) {
                return $response;
            }
        }

        $routeResponse = $this->executeCallback($match->callback, $match->args);

        foreach ($match->after as $filter) {
            if (empty($filter)) {
                continue;
            }
            array_unshift($match->args, $routeResponse);
            $response = $this->executeCallback($this->getFilterCallback($filter), $match->args, true);
            if (!is_null($response)) {
                return $response;
            }
        }

        return $routeResponse;
    }
1237165
private function executeController($controller, Route $method, $matches) {

		if(false === is_object($controller)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type object, "%s" given', __METHOD__, gettype($controller)), E_USER_ERROR);
		}

		if(false === is_array($matches)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($matches)), E_USER_ERROR);
		}

		//Load the module dispatch file if exists and readable
		$this -> loadBoot($method -> getModule());

		//Execute start method if controller supports it
		if(true === is_callable([$controller, '__start'])) {
			call_user_func_array([$controller, '__start'], []);
		}

		//Execute main function
		$action = Application :: get(['prefix', 'action']) . $method -> getAction();

		//Trigger error if main function does not exists
		if(false === is_callable([$controller, $action])) {
			return trigger_error(sprintf('Method "%s" does not exists in "%s" controller', Application :: get(['prefix', 'action']) . ucfirst($method -> getAction()), $method -> getController()), E_USER_ERROR);
		}

		call_user_func_array([$controller, $action], $matches);

		//Execute end method if controller supports it
		if(true === is_callable([$controller, '__end'])) {
			call_user_func_array([$controller, '__end'], []);
		}
	}
167291
public function dispatchAction($controller)
    {
        $action = $this->matchRoute[key($this->matchRoute)]['action'] . 'Action';

        $viewModel = $controller->$action();

        if ($viewModel instanceof ViewModel) {
            $this->view->setVariables($viewModel->getVariables());
        }
    }