I'm having trouble with accessing the current request in the Conditional extender. I'm trying to add a gambit conditionally based on the current user's attributes. Here's what I've tried:
(new Extend\Conditional)
->when(
function (?ServerRequestInterface $request) {
return InterestingGambit::canUseInterestingGambit(RequestUtil::getActor($request));
}, [
(new Extend\SimpleFlarumSearch(DiscussionSearcher::class))->addGambit(InterestingGambit::class)
]),
However, this results in the following error:
Illuminate\Contracts\Container\BindingResolutionException: Target [Psr\Http\Message\ServerRequestInterface] is not instantiable.
I've also tried using resolve(ServerRequestInterface::class)
but the error is the same. How can I properly access the current request in this context?