@@ -41,44 +41,49 @@ public function getTopicByAttribute(mixed $record): string|null
4141 }
4242
4343 // Route Function
44- private function appRunningWithRequest (): bool
44+ protected function appRunningWithRequest (): bool
4545 {
4646 return Route::current () !== null ;
4747 }
4848
49- private function getTopicByRoute (): string | null
49+ protected function getActionClassAndMethod (): array
5050 {
51- $ topicId = null ;
5251 $ route = Route::current ();
53-
5452 if (!isset ($ route ->getAction ()['controller ' ])) {
55- return null ;
53+ return [ null , null ] ;
5654 }
57-
5855 if ($ this ->isLivewire () && app ('livewire ' )->isLivewireRequest ()) {
59- [$ controller , $ method ] = $ this ->getMainLivewireClass ();
60- } else {
61- [$ controller , $ method ] = explode ('@ ' , $ route ->getAction ()['controller ' ]);
56+ return $ this ->getMainLivewireClass ();
6257 }
6358
64- if ($ controller !== null ) {
65- $ topicId = $ this ->getTopicIdByReflection ($ controller , $ method );
59+ $ action = $ route ->getAction ()['uses ' ] ?? $ route ->getAction ()['controller ' ];
60+ return explode ('@ ' , $ action );
61+ }
62+
63+ protected function getTopicByRoute (): string |null
64+ {
65+ [$ actionClass , $ method ] = $ this ->getActionClassAndMethod ();
66+
67+ $ topicId = null ;
68+
69+ if ($ actionClass !== null ) {
70+ $ topicId = $ this ->getTopicIdByReflection ($ actionClass , $ method );
6671
6772 if ($ topicId === false ) {
68- $ topicId = $ this ->getTopicIdByRegex ($ controller , $ method );
73+ $ topicId = $ this ->getTopicIdByRegex ($ actionClass , $ method );
6974 }
7075 }
7176
7277 return $ topicId ;
7378 }
7479
7580 // Job function
76- private function appRunningWithJob (): bool
81+ protected function appRunningWithJob (): bool
7782 {
7883 return (isset ($ e ->job ) || app ()->bound ('queue.worker ' ));
7984 }
8085
81- private function getJobClass (): string |null
86+ protected function getJobClass (): string |null
8287 {
8388 if (!app ()->bound ('queue.worker ' )) {
8489 return null ;
@@ -93,7 +98,7 @@ private function getJobClass(): string|null
9398 return null ;
9499 }
95100
96- private function getTopicIdByJob (): string |int |null
101+ protected function getTopicIdByJob (): string |int |null
97102 {
98103 $ topicId = null ;
99104 $ jobClass = $ this ->getJobClass ();
@@ -110,12 +115,12 @@ private function getTopicIdByJob(): string|int|null
110115 }
111116
112117 // Command function
113- private function appRunningWithCommand (): bool
118+ protected function appRunningWithCommand (): bool
114119 {
115120 return app ()->runningInConsole ();
116121 }
117122
118- private function getCommandClass (): string |null
123+ protected function getCommandClass (): string |null
119124 {
120125 $ filePath = $ this ->exception ->getFile ();
121126
@@ -137,7 +142,7 @@ private function getCommandClass(): string|null
137142 return null ;
138143 }
139144
140- private function getTopicIdByCommand (): string |int |null
145+ protected function getTopicIdByCommand (): string |int |null
141146 {
142147 $ topicId = null ;
143148 $ commandClass = $ this ->getCommandClass ();
@@ -154,7 +159,7 @@ private function getTopicIdByCommand(): string|int|null
154159 }
155160
156161 // General function
157- private function getTopicIdByReflection (string $ class , string $ method ): string |int |null |bool
162+ protected function getTopicIdByReflection (string $ class , string $ method ): string |int |null |bool
158163 {
159164 try {
160165 $ reflectionMethod = new ReflectionMethod ($ class , $ method );
@@ -174,7 +179,7 @@ private function getTopicIdByReflection(string $class, string $method): string|i
174179 return false ;
175180 }
176181
177- private function getTopicIdByRegex (string $ class , string $ method ): string |int |null
182+ protected function getTopicIdByRegex (string $ class , string $ method ): string |int |null
178183 {
179184 try {
180185 $ filePath = base_path (str_replace ('App ' , 'app ' , $ class ) . '.php ' );
@@ -216,7 +221,7 @@ private function getTopicIdByRegex(string $class, string $method): string|int|nu
216221 return null ;
217222 }
218223
219- private function isLivewire (): bool
224+ protected function isLivewire (): bool
220225 {
221226 return class_exists (\Livewire \Livewire::class);
222227 }
0 commit comments