1
0
mirror of https://github.com/flarum/core.git synced 2025-08-14 04:14:06 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
luceos
aea72957fd Apply fixes from StyleCI
[ci skip] [skip ci]
2021-06-28 09:37:49 +00:00
Daniel Klabbers
838d9c5106 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.
2021-06-28 11:36:03 +02:00
2 changed files with 15 additions and 1 deletions

View File

@@ -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);

View File

@@ -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
);
};
});
}
/**