public function applyMiddleware(...$names)
    {
        foreach ($names as $name) {
            if (!$this->_collection->middlewareExists($name)) {
                $message = "Cannot apply '$name' middleware or middleware group. " .
                    'Use registerMiddleware() to register middleware.';
                throw new RuntimeException($message);
            }
        }
        $this->middleware = array_unique(array_merge($this->middleware, $names));

        return $this;
    }
public function applyMiddleware(...$names)
    {
        foreach ($names as $name) {
            if (!$this->_collection->middlewareExists($name)) {
                $message = "Cannot apply '$name' middleware or middleware group. " .
                    'Use registerMiddleware() to register middleware.';
                throw new RuntimeException($message);
            }
        }
        $this->middleware = array_unique(array_merge($this->middleware, $names));

        return $this;
    }
public function applyMiddleware ( ... $ names ) { foreach ( $ names as $ name ) { if ( ! $ this -> _collection -> middlewareExists ( $ name ) ) { $ message = "Cannot apply '$name' middleware or middleware group. " . 'Use registerMiddleware() to register middleware.' ; throw new RuntimeException ( $ message ) ; } } $ this -> middleware = array_unique ( array_merge ( $ this -> middleware , $ names ) ) ; return $ this ; }
Apply a middleware to the current route scope.

Requires middleware to be registered via `registerMiddleware()`

@param string ...$names The names of the middleware to apply to the current scope.
@return $this
@see \Cake\Routing\RouteCollection::addMiddlewareToScope()
Apply a middleware to the current route scope .