mirror of
https://github.com/flarum/core.git
synced 2025-08-07 17:07:19 +02:00
Allow easier extensibility of page document
This allows extensions to: - mutate the json api document sent with php documents - override/interact with the Document Right now extensions need to replace the complete Frontend class in order to interact with the document. Let's abstract into ioc so that advanced devs can interact with it.
This commit is contained in:
@@ -49,7 +49,9 @@ class Frontend
|
||||
{
|
||||
$forumDocument = $this->getForumDocument($request);
|
||||
|
||||
$document = new Document($this->view, $forumDocument, $request);
|
||||
$responseDocument = resolve('flarum.frontend.document');
|
||||
|
||||
$document = $responseDocument($forumDocument, $request);
|
||||
|
||||
$this->populate($document, $request);
|
||||
|
||||
|
@@ -16,6 +16,8 @@ use Flarum\Http\UrlGenerator;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\View\Factory as ViewFactory;
|
||||
use Illuminate\View\Factory;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
||||
class FrontendServiceProvider extends AbstractServiceProvider
|
||||
{
|
||||
@@ -57,6 +59,16 @@ class FrontendServiceProvider extends AbstractServiceProvider
|
||||
return $frontend;
|
||||
};
|
||||
});
|
||||
|
||||
$this->container->singleton('flarum.frontend.document', function (Container $container) {
|
||||
return function (array $apiDocument, Request $request) use ($container){
|
||||
return new Document(
|
||||
$container->make(Factory::class),
|
||||
$apiDocument,
|
||||
$request
|
||||
);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user