Layton/App.php
public function connectMiddlewares($controller, $method, MiddleWares $middleWares, $decorators = [])
    {
        $isClosure = is_callable($controller);
        if ($middleWares->valid()) {
            if ($isClosure) {
                $next = $this->getInvokeMiddlewareNext($controller, $middleWares, $decorators);
            } else {
                $next = $this->getControllerMiddlewareNext($controller, $method, $middleWares, $decorators);
            }
            $middleWares->withNextArgs($next);
            $response = $this->injectionClass($middleWares->current(), 'handle', $middleWares->getNextArgs());
        } else {
            if ($isClosure) {
                $controller = $this->closureBinder($controller);
                $response = $this->injectionClosure($controller, $decorators);
            } else {
                $response = $this->injectionClass($controller, $method, [], $decorators);
            }
        }

        if ($response instanceof Response) {
            $this->sendByResponse($response);
        }
    }
public function connectMiddlewares($controller, $method, MiddleWares $middleWares, $decorators = [])
    {
        $isClosure = is_callable($controller);
        if ($middleWares->valid()) {
            if ($isClosure) {
                $next = $this->getInvokeMiddlewareNext($controller, $middleWares, $decorators);
            } else {
                $next = $this->getControllerMiddlewareNext($controller, $method, $middleWares, $decorators);
            }
            $middleWares->withNextArgs($next);
            $response = $this->injectionClass($middleWares->current(), 'handle', $middleWares->getNextArgs());
        } else {
            if ($isClosure) {
                $controller = $this->closureBinder($controller);
                $response = $this->injectionClosure($controller, $decorators);
            } else {
                $response = $this->injectionClass($controller, $method, [], $decorators);
            }
        }

        if ($response instanceof Response) {
            $this->sendByResponse($response);
        }
    }
public function connectMiddlewares ( $ controller , $ method , MiddleWares $ middleWares , $ decorators = [ ] ) { $ isClosure = is_callable ( $ controller ) ; if ( $ middleWares -> valid ( ) ) { if ( $ isClosure ) { $ next = $ this -> getInvokeMiddlewareNext ( $ controller , $ middleWares , $ decorators ) ; } else { $ next = $ this -> getControllerMiddlewareNext ( $ controller , $ method , $ middleWares , $ decorators ) ; } $ middleWares -> withNextArgs ( $ next ) ; $ response = $ this -> injectionClass ( $ middleWares -> current ( ) , 'handle' , $ middleWares -> getNextArgs ( ) ) ; } else { if ( $ isClosure ) { $ controller = $ this -> closureBinder ( $ controller ) ; $ response = $ this -> injectionClosure ( $ controller , $ decorators ) ; } else { $ response = $ this -> injectionClass ( $ controller , $ method , [ ] , $ decorators ) ; } } if ( $ response instanceof Response ) { $ this -> sendByResponse ( $ response ) ; } }
Call middlewares and controller.

@param callback $controller
@param string $method
@param MiddleWares $middleWares
Call middlewares and controller .