mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
refactor
This commit is contained in:
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user