File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
src/LiveComponent/src/Util Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 24
24
*/
25
25
final class LiveComponentStack extends ComponentStack
26
26
{
27
+ /** @var array<class-string, bool> */
28
+ private array $ cacheLiveComponents = [];
29
+
27
30
public function __construct (private readonly ComponentStack $ componentStack )
28
31
{
29
32
}
30
33
31
34
public function getCurrentLiveComponent (): ?MountedComponent
32
35
{
33
36
foreach ($ this ->componentStack as $ mountedComponent ) {
34
- if ($ this ->isLiveComponent ($ mountedComponent ->getComponent ()::class)) {
37
+ $ componentClass = $ mountedComponent ->getComponent ()::class;
38
+ if ($ this ->cacheLiveComponents [$ componentClass ] ??= $ this ->isLiveComponent ($ componentClass )) {
35
39
return $ mountedComponent ;
36
40
}
37
41
}
@@ -41,9 +45,7 @@ public function getCurrentLiveComponent(): ?MountedComponent
41
45
42
46
private function isLiveComponent (string $ classname ): bool
43
47
{
44
- static $ cache = [];
45
-
46
- return $ cache [$ classname ] ??= [] !== (new \ReflectionClass ($ classname ))->getAttributes (AsLiveComponent::class);
48
+ return [] !== (new \ReflectionClass ($ classname ))->getAttributes (AsLiveComponent::class);
47
49
}
48
50
49
51
public function getCurrentComponent (): ?MountedComponent
You can’t perform that action at this time.
0 commit comments