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