In extend.php
I have a code like:
use Illuminate\Container\Container;
use Flarum\Frontend\Document;
use Flarum\Extend;
$container = Container::getInstance();
/** @var HtmlParts */
$htmlParts = $container->get(HtmlParts::class);
return [
(new Extend\Frontend('forum'))
->content(function (Document $document) use ($htmlParts) {
// $document doesn't seem to have anything related to the current request or user,
// cannot pass them to getBootstrapModalHtml()
$document->foot = [$htmlParts->getBootstrapModalHtml()];
}),
];
And here is the [shortened] code of HtmlParts
:
use Laminas\Diactoros\ServerRequest;
use Flarum\User\User;
class HtmlParts {
public function __construct (ServerRequest $serverRequest, User $user) {
// $serverRequest is not a current request, doesn't has access to the current user
// $user is not the current user, it's empty
}
public function getBootstrapModalHtml () {
// How to access the current user?
// app('flarum.user') is outdated and doesn't return anything anyway
}
}
I can't figure out how to access the current user.