Skip to content

Commit

Permalink
Fix frontend factory so it includes controller content
Browse files Browse the repository at this point in the history
  • Loading branch information
garygreen committed Mar 17, 2023
1 parent 8372363 commit 83fccfd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 8 additions & 2 deletions framework/core/src/Forum/ForumServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,14 @@ public function register()
return $assets;
});

$this->container->bind('flarum.frontend.forum', function (Container $container) {
return $container->make('flarum.frontend.factory')('forum');
$this->container->bind('flarum.frontend.forum', function (Container $container, array $args = []) {
$frontend = $container->make('flarum.frontend.factory')('forum');

foreach ($args[0] ?? [] as $content) {
$frontend->content(is_callable($content) ? $content : $container->make($content));
}

return $frontend;
});

$this->container->singleton('flarum.forum.discussions.sortmap', function () {
Expand Down
6 changes: 1 addition & 5 deletions framework/core/src/Http/RouteHandlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ public function toController($controller): Closure
public function toFrontend(string $frontend, $content = null): Closure
{
return $this->toController(function (Container $container) use ($frontend, $content) {
$frontend = $container->make("flarum.frontend.$frontend");

if ($content) {
$frontend->content(is_callable($content) ? $content : $container->make($content));
}
$frontend = $container->make("flarum.frontend.$frontend", [[$content]]);

return new FrontendController($frontend);
});
Expand Down

0 comments on commit 83fccfd

Please sign in to comment.