|
1 | 1 | // This file was generated from php-templates/views.php, do not edit directly
|
2 | 2 | export default `
|
3 |
| -function vsCodeFindBladeFiles($path) |
4 |
| -{ |
5 |
| - $paths = []; |
| 3 | +$blade = new class { |
| 4 | + public function findFiles($path) |
| 5 | + { |
| 6 | + $paths = []; |
6 | 7 |
|
7 |
| - if (!is_dir($path)) { |
8 |
| - return $paths; |
9 |
| - } |
| 8 | + if (!is_dir($path)) { |
| 9 | + return $paths; |
| 10 | + } |
10 | 11 |
|
11 |
| - foreach ( |
12 |
| - \\Symfony\\Component\\Finder\\Finder::create() |
| 12 | + $files = \\Symfony\\Component\\Finder\\Finder::create() |
13 | 13 | ->files()
|
14 | 14 | ->name("*.blade.php")
|
15 |
| - ->in($path) |
16 |
| - as $file |
17 |
| - ) { |
18 |
| - $paths[] = [ |
19 |
| - "path" => str_replace(base_path(DIRECTORY_SEPARATOR), '', $file->getRealPath()), |
20 |
| - "isVendor" => str_contains($file->getRealPath(), base_path("vendor")), |
21 |
| - "key" => \\Illuminate\\Support\\Str::of($file->getRealPath()) |
22 |
| - ->replace(realpath($path), "") |
23 |
| - ->replace(".blade.php", "") |
24 |
| - ->ltrim(DIRECTORY_SEPARATOR) |
25 |
| - ->replace(DIRECTORY_SEPARATOR, ".") |
26 |
| - ]; |
| 15 | + ->in($path); |
| 16 | +
|
| 17 | + foreach ($files as $file) { |
| 18 | + $paths[] = [ |
| 19 | + "path" => str_replace(base_path(DIRECTORY_SEPARATOR), '', $file->getRealPath()), |
| 20 | + "isVendor" => str_contains($file->getRealPath(), base_path("vendor")), |
| 21 | + "key" => \\Illuminate\\Support\\Str::of($file->getRealPath()) |
| 22 | + ->replace(realpath($path), "") |
| 23 | + ->replace(".blade.php", "") |
| 24 | + ->ltrim(DIRECTORY_SEPARATOR) |
| 25 | + ->replace(DIRECTORY_SEPARATOR, ".") |
| 26 | + ]; |
| 27 | + } |
| 28 | +
|
| 29 | + return $paths; |
27 | 30 | }
|
| 31 | +}; |
28 | 32 |
|
29 |
| - return $paths; |
30 |
| -} |
31 | 33 | $paths = collect(
|
32 | 34 | app("view")
|
33 | 35 | ->getFinder()
|
34 | 36 | ->getPaths()
|
35 |
| -)->flatMap(function ($path) { |
36 |
| - return vsCodeFindBladeFiles($path); |
37 |
| -}); |
| 37 | +)->flatMap(fn($path) => $blade->findFiles($path)); |
38 | 38 |
|
39 | 39 | $hints = collect(
|
40 | 40 | app("view")
|
41 | 41 | ->getFinder()
|
42 | 42 | ->getHints()
|
43 |
| -)->flatMap(function ($paths, $key) { |
44 |
| - return collect($paths)->flatMap(function ($path) use ($key) { |
45 |
| - return collect(vsCodeFindBladeFiles($path))->map(function ($value) use ( |
46 |
| - $key |
47 |
| - ) { |
48 |
| - return array_merge($value, ["key" => "{$key}::{$value["key"]}"]); |
49 |
| - }); |
50 |
| - }); |
51 |
| -}); |
| 43 | +)->flatMap( |
| 44 | + fn($paths, $key) => collect($paths)->flatMap( |
| 45 | + fn($path) => collect($blade->findFiles($path))->map( |
| 46 | + fn($value) => array_merge($value, ["key" => "{$key}::{$value["key"]}"]) |
| 47 | + ) |
| 48 | + ) |
| 49 | +); |
52 | 50 |
|
53 | 51 | [$local, $vendor] = $paths
|
54 | 52 | ->merge($hints)
|
55 | 53 | ->values()
|
56 |
| - ->partition(function ($v) { |
57 |
| - return !$v["isVendor"]; |
58 |
| - }); |
| 54 | + ->partition(fn($v) => !$v["isVendor"]); |
59 | 55 |
|
60 | 56 | echo $local
|
61 | 57 | ->sortBy("key", SORT_NATURAL)
|
|
0 commit comments