public function dispatch($controller)
    {
        if ($this->can_proceed()) {
            // As this is the correct route, apply middleware stack.
            $this->apply_middleware();

            // Passed all middleware.
            if ($this->can_proceed()) {
                list($class, $action) = \explode('@', $controller);

                if ($action === null) {
                    $action = 'index';
                }

                $fqn = '\\Theme\\Http\\Controllers\\' . $class;

                if (\class_exists($fqn)) {
                    Container::resolve_method(
                        Container::resolve($fqn),
                        $action
                    );
                } else {
                    throw new Exception("The controller {$fqn} could not be found.");
                }

                $this->has_matched_route = true;

                echo \ob_get_clean();
            }
        }
    }
public function dispatch($controller)
    {
        if ($this->can_proceed()) {
            // As this is the correct route, apply middleware stack.
            $this->apply_middleware();

            // Passed all middleware.
            if ($this->can_proceed()) {
                list($class, $action) = \explode('@', $controller);

                if ($action === null) {
                    $action = 'index';
                }

                $fqn = '\\Theme\\Http\\Controllers\\' . $class;

                if (\class_exists($fqn)) {
                    Container::resolve_method(
                        Container::resolve($fqn),
                        $action
                    );
                } else {
                    throw new Exception("The controller {$fqn} could not be found.");
                }

                $this->has_matched_route = true;

                echo \ob_get_clean();
            }
        }
    }
public function dispatch ( $ controller ) { if ( $ this -> can_proceed ( ) ) { // As this is the correct route, apply middleware stack. $ this -> apply_middleware ( ) ; // Passed all middleware. if ( $ this -> can_proceed ( ) ) { list ( $ class , $ action ) = \ explode ( '@' , $ controller ) ; if ( $ action === null ) { $ action = 'index' ; } $ fqn = '\\Theme\\Http\\Controllers\\' . $ class ; if ( \ class_exists ( $ fqn ) ) { Container :: resolve_method ( Container :: resolve ( $ fqn ) , $ action ) ; } else { throw new Exception ( "The controller {$fqn} could not be found." ) ; } $ this -> has_matched_route = true ; echo \ ob_get_clean ( ) ; } } }
Dispatch a controller action.

The dispatched action and the controller class are auto-wired.

@since  1.0.0

@throws Exception If the supplied controller doesn't exist.

@param  string $controller The controller name followed by the action, separated by an @.
eg. "My_Controller@MyAction"
If no action is supplied, then 'index' is presumed.
Dispatch a controller action .