Skip to content

Commit fdd6b8b

Browse files
authored
refactor(core): simplify view component resolution (#1783)
1 parent 288ac6e commit fdd6b8b

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"adam-paterson/oauth2-slack": "^1.1",
5050
"aws/aws-sdk-php": "^3.338.0",
5151
"azure-oss/storage-blob-flysystem": "^1.2",
52+
"brianium/paratest": "^7.14",
5253
"carthage-software/mago": "1.0.0-beta.28",
5354
"depotwarehouse/oauth2-twitch": "^1.3",
5455
"guzzlehttp/psr7": "^2.6.1",
@@ -87,8 +88,7 @@
8788
"tempest/blade": "dev-main",
8889
"thenetworg/oauth2-azure": "^2.2",
8990
"twig/twig": "^3.16",
90-
"wohali/oauth2-discord-new": "^1.2",
91-
"brianium/paratest": "^7.14"
91+
"wohali/oauth2-discord-new": "^1.2"
9292
},
9393
"replace": {
9494
"tempest/auth": "self.version",

src/Tempest/Framework/Commands/MetaViewComponentCommand.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,13 @@ private function makeData(ViewComponent $viewComponent): ImmutableArray
6060
private function resolveViewComponent(string $viewComponent): ?ViewComponent
6161
{
6262
if (is_file($viewComponent)) {
63-
foreach ($this->viewConfig->viewComponents as $registeredViewComponent) {
64-
if ($registeredViewComponent->file !== $viewComponent) {
65-
continue;
66-
}
67-
68-
$viewComponent = $registeredViewComponent;
69-
70-
break;
71-
}
72-
} else {
73-
$viewComponent = $this->viewConfig->viewComponents[$viewComponent] ?? null;
63+
return array_find(
64+
array: $this->viewConfig->viewComponents,
65+
callback: fn ($registeredViewComponent) => $registeredViewComponent->file === $viewComponent,
66+
);
7467
}
7568

76-
return $viewComponent;
69+
return $this->viewConfig->viewComponents[$viewComponent] ?? null;
7770
}
7871

7972
private function resolveSlots(ViewComponent $viewComponent): ImmutableArray

0 commit comments

Comments
 (0)