This commit is contained in:
Dan Harrin
2022-04-20 21:31:59 +01:00
parent dee621be83
commit eeae0ddd87
3 changed files with 9 additions and 8 deletions
+5 -4
View File
@@ -178,11 +178,12 @@ class FilamentManager
public function renderHook(string $name): HtmlString
{
$output = collect($this->renderHooks[$name] ?? [])
->map(fn (callable $hook): string => (string) app()->call($renderHook))
->implode();
$hooks = array_map(
fn (callable $hook): string => (string) app()->call($hook),
$this->renderHooks[$name] ?? [],
);
return new HtmlString($output);
return new HtmlString(implode('', $hooks));
}
public function getNavigation(): array
@@ -1 +1 @@
Hello, foo!
bar
@@ -8,7 +8,7 @@ use Illuminate\Support\HtmlString;
uses(TestCase::class);
test('render hooks can be registered', function () {
Filament::registerRenderHook('foo', function () {
Filament::registerRenderHook('foo', function (): string {
return Blade::render('bar');
});
@@ -18,11 +18,11 @@ test('render hooks can be registered', function () {
});
test('render hooks can render view files', function () {
Filament::registerRenderHook('view-foo', function () {
Filament::registerRenderHook('view-foo', function (): \Illuminate\Contracts\View\View {
return view('fixtures.pages.render-hooks.foo');
});
expect(Filament::renderHook('view-foo'))
->toBeInstanceOf(HtmlString::class)
->toHtml()->toContain('Hello, foo!');
->toHtml()->toContain('bar');
});