On Saturday, May 13, 2017 at 7:31:20 PM UTC+2, Woody Gilk wrote:

> My question is more about how the interfaces proposed by David would do 
> this delegation. Right now I don't see how it would be possible without 
> passing a factory to a middleware, which (I thought) he was attempting to 
> avoid.
>
> --
> Woody Gilk
> http://about.me/shadowhand
>

interface RequestHandlerInterface
{
    public function dispatch(ServerRequestInterface $request) : 
ResponseInterface;
}


interface Middleware {
    function dispatch(RequestHandlerInterface $next) : 
RequestHandlerInterface;
}


class ResetParsedBody implements Middleware {
    function dispatch(RequestHandlerInterface $next) : 
RequestHandlerInterface
    {
        return new class($next) implements RequestHandlerInterface {
            private $next;


            public function __construct(RequestHandlerInterface $next)
            {
                $this->next = $next;
            }


            public function dispatch(ServerRequestInterface $request) : 
ResponseInterface
            {
                return $this->next->dispatch($request->withParsedBody(null
));
            }
        };
    }
}

Would this answer your question?

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/3f9f2e9a-6f67-4d3d-8a43-cf9f08cae679%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to