5
5
use DutchCodingCompany \FilamentDeveloperLogins \Livewire \MenuLogins ;
6
6
use DutchCodingCompany \FilamentDeveloperLogins \View \Components \DeveloperLogins ;
7
7
use Filament \Facades \Filament ;
8
+ use Filament \Panel ;
8
9
use Filament \Support \Concerns \EvaluatesClosures ;
9
10
use Filament \Support \Facades \FilamentView ;
10
11
use Filament \View \PanelsRenderHook ;
@@ -44,17 +45,16 @@ public function packageBooted(): void
44
45
45
46
protected static function registerRenderHooks (): void
46
47
{
47
- $ panel = Filament::getCurrentPanel ();
48
- if (is_null ($ panel ) || ! $ panel ->hasPlugin ('filament-developer-logins ' )) {
49
- return ;
50
- }
51
-
52
- /** @var FilamentDeveloperLoginsPlugin $plugin */
53
- $ plugin = $ panel ->getPlugin ('filament-developer-logins ' );
54
-
55
48
FilamentView::registerRenderHook (
56
49
PanelsRenderHook::AUTH_LOGIN_FORM_AFTER ,
57
- static function () use ($ plugin ) : ?string {
50
+ static function (): ?string {
51
+ $ panel = Filament::getCurrentPanel ();
52
+ if (! self ::panelHasPlugin ($ panel )) {
53
+ return null ;
54
+ }
55
+
56
+ /** @var FilamentDeveloperLoginsPlugin $plugin */
57
+ $ plugin = $ panel ->getPlugin ('filament-developer-logins ' );
58
58
if (! $ plugin ->getEnabled ()) {
59
59
return null ;
60
60
}
@@ -65,7 +65,14 @@ static function () use ($plugin) : ?string {
65
65
66
66
FilamentView::registerRenderHook (
67
67
PanelsRenderHook::GLOBAL_SEARCH_AFTER ,
68
- static function () use ($ plugin ) : ?string {
68
+ static function (): ?string {
69
+ $ panel = Filament::getCurrentPanel ();
70
+ if (! self ::panelHasPlugin ($ panel )) {
71
+ return null ;
72
+ }
73
+
74
+ /** @var FilamentDeveloperLoginsPlugin $plugin */
75
+ $ plugin = $ panel ->getPlugin ('filament-developer-logins ' );
69
76
if (! $ plugin ->getEnabled () || ! $ plugin ->getSwitchable ()) {
70
77
return null ;
71
78
}
@@ -74,4 +81,9 @@ static function () use ($plugin) : ?string {
74
81
},
75
82
);
76
83
}
84
+
85
+ protected static function panelHasPlugin (?Panel $ panel ): bool
86
+ {
87
+ return ! is_null ($ panel ) && $ panel ->hasPlugin ('filament-developer-logins ' );
88
+ }
77
89
}
0 commit comments