Skip to content

Commit ab53f06

Browse files
committed
Add blade component directory discovery and registration to BladePlugin
1 parent d660b36 commit ab53f06

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

src/Plugins/BladePlugin.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,36 @@ public function __construct(
1818

1919
public function discover(FinderFactory $finders): iterable
2020
{
21-
return $finders
22-
->bladeComponentFileFinder()
23-
->withModuleInfo()
24-
->values()
25-
->map(fn(ModuleFileInfo $component) => [
26-
'prefix' => $component->module()->name,
27-
'fqcn' => $component->fullyQualifiedClassName(),
28-
]);
21+
return [
22+
'files' => $finders
23+
->bladeComponentFileFinder()
24+
->withModuleInfo()
25+
->values()
26+
->map(fn(ModuleFileInfo $component) => [
27+
'prefix' => $component->module()->name,
28+
'fqcn' => $component->fullyQualifiedClassName(),
29+
])
30+
->toArray(),
31+
'directories' => $finders
32+
->bladeComponentDirectoryFinder()
33+
->withModuleInfo()
34+
->values()
35+
->map(fn(ModuleFileInfo $component) => [
36+
'prefix' => $component->module()->name,
37+
'namespace' => $component->module()->qualify('View\\Components'),
38+
])
39+
->toArray(),
40+
];
2941
}
3042

3143
public function handle(Collection $data)
3244
{
33-
$data->each(fn(array $row) => $this->blade->component($row['fqcn'], null, $row['prefix']));
45+
foreach ($data['files'] as $config) {
46+
$this->blade->component($config['fqcn'], null, $config['prefix']);
47+
}
48+
49+
foreach ($data['directories'] as $config) {
50+
$this->blade->componentNamespace($config['namespace'], $config['prefix']);
51+
}
3452
}
3553
}

0 commit comments

Comments
 (0)