private function executeRouteMiddleware(Route &$route, $position, $method)
    {
        $method = strtoupper($method);

        /** @var Middleware[] $middleware */
        $middleware = array();
        $continue   = true;

        // Get all global middleware's.
        if (isset(
                $this->middleware['global'],
                $this->middleware['global'][$position])
            && count($this->middleware['global'][$position]) > 0) {

            $middleware = array_merge($middleware, $this->middleware['global'][$position]);
        }

        // Group middleware if defined.
        if ($route->getGroup() !== null
            &&  isset($this->middleware[$route->getGroup()],
                $this->middleware[$route->getGroup()][$position])
            && count($this->middleware[$route->getGroup()][$position]) > 0) {
            $middleware = array_merge($middleware, $this->middleware[$route->getGroup()][$position]);
        }


        // Will execute all middleware in order..:
        foreach ($middleware as $trigger)
        {
            if (count($trigger->getMethods()) === 0
            ||  in_array(strtoupper($method), $trigger->getMethods())) {

                if ($this->executeMiddleware($trigger) === false) {
                    $continue = false;
                }
            }
        }

        return $continue;
    }
private function executeRouteMiddleware(Route &$route, $position, $method)
    {
        $method = strtoupper($method);

        /** @var Middleware[] $middleware */
        $middleware = array();
        $continue   = true;

        // Get all global middleware's.
        if (isset(
                $this->middleware['global'],
                $this->middleware['global'][$position])
            && count($this->middleware['global'][$position]) > 0) {

            $middleware = array_merge($middleware, $this->middleware['global'][$position]);
        }

        // Group middleware if defined.
        if ($route->getGroup() !== null
            &&  isset($this->middleware[$route->getGroup()],
                $this->middleware[$route->getGroup()][$position])
            && count($this->middleware[$route->getGroup()][$position]) > 0) {
            $middleware = array_merge($middleware, $this->middleware[$route->getGroup()][$position]);
        }


        // Will execute all middleware in order..:
        foreach ($middleware as $trigger)
        {
            if (count($trigger->getMethods()) === 0
            ||  in_array(strtoupper($method), $trigger->getMethods())) {

                if ($this->executeMiddleware($trigger) === false) {
                    $continue = false;
                }
            }
        }

        return $continue;
    }
private function executeRouteMiddleware ( Route & $ route , $ position , $ method ) { $ method = strtoupper ( $ method ) ; /** @var Middleware[] $middleware */ $ middleware = array ( ) ; $ continue = true ; // Get all global middleware's. if ( isset ( $ this -> middleware [ 'global' ] , $ this -> middleware [ 'global' ] [ $ position ] ) && count ( $ this -> middleware [ 'global' ] [ $ position ] ) > 0 ) { $ middleware = array_merge ( $ middleware , $ this -> middleware [ 'global' ] [ $ position ] ) ; } // Group middleware if defined. if ( $ route -> getGroup ( ) !== null && isset ( $ this -> middleware [ $ route -> getGroup ( ) ] , $ this -> middleware [ $ route -> getGroup ( ) ] [ $ position ] ) && count ( $ this -> middleware [ $ route -> getGroup ( ) ] [ $ position ] ) > 0 ) { $ middleware = array_merge ( $ middleware , $ this -> middleware [ $ route -> getGroup ( ) ] [ $ position ] ) ; } // Will execute all middleware in order..: foreach ( $ middleware as $ trigger ) { if ( count ( $ trigger -> getMethods ( ) ) === 0 || in_array ( strtoupper ( $ method ) , $ trigger -> getMethods ( ) ) ) { if ( $ this -> executeMiddleware ( $ trigger ) === false ) { $ continue = false ; } } } return $ continue ; }
Execute middleware found for the route.

@param Route $route

@param string $position 'before' or 'after'

@param string $method

@return bool Continue?
Execute middleware found for the route .