src/Stack.php
private function addMiddleware($middleware, $args, $push = true)
    {
        $instance = $this->resolve($middleware);

        $types = $this->getTypes($instance);

        if (!count($types)) {
            throw new InvalidArgumentException('The first argument must be an instance of PrepareableInterface, RespondableInterface or CloseableInterface.');
        }

        //Replace middleware definition with instance
        $args[0] = $instance;

        foreach ($types as $type) {
            if ($push) {
                array_push($this->{$type . 'Middlewares'}, $args);
            } else {
                array_unshift($this->{$type . 'Middlewares'}, $args);
            }
        }

    }
private function addMiddleware($middleware, $args, $push = true)
    {
        $instance = $this->resolve($middleware);

        $types = $this->getTypes($instance);

        if (!count($types)) {
            throw new InvalidArgumentException('The first argument must be an instance of PrepareableInterface, RespondableInterface or CloseableInterface.');
        }

        //Replace middleware definition with instance
        $args[0] = $instance;

        foreach ($types as $type) {
            if ($push) {
                array_push($this->{$type . 'Middlewares'}, $args);
            } else {
                array_unshift($this->{$type . 'Middlewares'}, $args);
            }
        }

    }
private function addMiddleware ( $ middleware , $ args , $ push = true ) { $ instance = $ this -> resolve ( $ middleware ) ; $ types = $ this -> getTypes ( $ instance ) ; if ( ! count ( $ types ) ) { throw new InvalidArgumentException ( 'The first argument must be an instance of PrepareableInterface, RespondableInterface or CloseableInterface.' ) ; } //Replace middleware definition with instance $ args [ 0 ] = $ instance ; foreach ( $ types as $ type ) { if ( $ push ) { array_push ( $ this -> { $ type . 'Middlewares' } , $ args ) ; } else { array_unshift ( $ this -> { $ type . 'Middlewares' } , $ args ) ; } } }
Adds a middleware to aggregates
@param mixed $middleware
@param array $args
@param bool $push Whether to push the middleware, false, or unshift, true
@throws InvalidArgumentException
Adds a middleware to aggregates