public function middlewares(array $middlewares = []) {
        if (!$this->isGroupe) {
            end($this->virtualRoutes['*']);
            $lastKey = key($this->virtualRoutes['*']);
            $this->virtualRoutes['*'][$lastKey]['middlewares'] = $middlewares;
        } else {
            end($this->virtualRoutes);
            $lastKeyOfFirstRound = key($this->virtualRoutes);

            if (!$this->isGroupeMiddlewares) {
                end($this->virtualRoutes[$lastKeyOfFirstRound]);
                $lastKeyOfSecondRound = key($this->virtualRoutes[$lastKeyOfFirstRound]);
                $this->virtualRoutes[$lastKeyOfFirstRound][$lastKeyOfSecondRound]['middlewares'] = $middlewares;
            } else {
                $this->isGroupe = FALSE;

                foreach ($this->virtualRoutes[$lastKeyOfFirstRound] as &$route) {
                    $hasMiddleware = end($route);
                    if (!is_array($hasMiddleware)) {
                        $route['middlewares'] = $middlewares;
                    } else {
                        foreach ($middlewares as $middleware) {
                            $route['middlewares'][] = $middleware;
                        }
                    }
                }
            }
        }
    }
public function middlewares(array $middlewares = []) {
        if (!$this->isGroupe) {
            end($this->virtualRoutes['*']);
            $lastKey = key($this->virtualRoutes['*']);
            $this->virtualRoutes['*'][$lastKey]['middlewares'] = $middlewares;
        } else {
            end($this->virtualRoutes);
            $lastKeyOfFirstRound = key($this->virtualRoutes);

            if (!$this->isGroupeMiddlewares) {
                end($this->virtualRoutes[$lastKeyOfFirstRound]);
                $lastKeyOfSecondRound = key($this->virtualRoutes[$lastKeyOfFirstRound]);
                $this->virtualRoutes[$lastKeyOfFirstRound][$lastKeyOfSecondRound]['middlewares'] = $middlewares;
            } else {
                $this->isGroupe = FALSE;

                foreach ($this->virtualRoutes[$lastKeyOfFirstRound] as &$route) {
                    $hasMiddleware = end($route);
                    if (!is_array($hasMiddleware)) {
                        $route['middlewares'] = $middlewares;
                    } else {
                        foreach ($middlewares as $middleware) {
                            $route['middlewares'][] = $middleware;
                        }
                    }
                }
            }
        }
    }
public function middlewares ( array $ middlewares = [ ] ) { if ( ! $ this -> isGroupe ) { end ( $ this -> virtualRoutes [ '*' ] ) ; $ lastKey = key ( $ this -> virtualRoutes [ '*' ] ) ; $ this -> virtualRoutes [ '*' ] [ $ lastKey ] [ 'middlewares' ] = $ middlewares ; } else { end ( $ this -> virtualRoutes ) ; $ lastKeyOfFirstRound = key ( $ this -> virtualRoutes ) ; if ( ! $ this -> isGroupeMiddlewares ) { end ( $ this -> virtualRoutes [ $ lastKeyOfFirstRound ] ) ; $ lastKeyOfSecondRound = key ( $ this -> virtualRoutes [ $ lastKeyOfFirstRound ] ) ; $ this -> virtualRoutes [ $ lastKeyOfFirstRound ] [ $ lastKeyOfSecondRound ] [ 'middlewares' ] = $ middlewares ; } else { $ this -> isGroupe = FALSE ; foreach ( $ this -> virtualRoutes [ $ lastKeyOfFirstRound ] as & $ route ) { $ hasMiddleware = end ( $ route ) ; if ( ! is_array ( $ hasMiddleware ) ) { $ route [ 'middlewares' ] = $ middlewares ; } else { foreach ( $ middlewares as $ middleware ) { $ route [ 'middlewares' ] [ ] = $ middleware ; } } } } } }
Adds middlewares to routes and route groups

@param array $middlewares
@return void
Adds middlewares to routes and route groups