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

Compare commits

...

3 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
Daniel Klabbers
e92c267cde update version constant for the next release 2021-06-22 23:38:47 +02:00
3 changed files with 16 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ class Application
*
* @var string
*/
const VERSION = '1.0.3';
const VERSION = '1.0.4-dev';
/**
* The IoC container for the Flarum application.

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