Skip to content

Commit 2dff43d

Browse files
fix(view): issue with child theme view paths
fix #60
1 parent 1fe1d03 commit 2dff43d

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

src/Theme.php

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -99,27 +99,6 @@ public function getAssetsPath(string $path = null): string
9999
return Config::get('themes-manager.symlink_path', 'themes') . '/' . mb_strtolower($this->vendor) . '/' . mb_strtolower($this->name) . ($path ? '/' . $path : '');
100100
}
101101

102-
/**
103-
* Get theme views paths.
104-
* Build Paths array.
105-
* All paths are relative to Config::get('themes-manager.directory').
106-
*/
107-
public function getViewPaths(string $path = ''): array
108-
{
109-
$paths = [];
110-
$theme = $this;
111-
112-
do {
113-
$viewsPath = $theme->getPath('resources/views' . ($path ? "/{$path}" : ''));
114-
115-
if (!in_array($viewsPath, $paths)) {
116-
$paths[] = $viewsPath;
117-
}
118-
} while ($theme = $theme->getParent());
119-
120-
return array_reverse($paths);
121-
}
122-
123102
/**
124103
* Set extra data.
125104
*/
@@ -356,28 +335,6 @@ public function url(string $url, bool $absolute = true): string
356335
return ltrim(str_replace('\\', '/', $url));
357336
}
358337

359-
/**
360-
* List theme's available layouts.
361-
*
362-
* @return \Illuminate\Support\Collection
363-
*/
364-
public function listLayouts()
365-
{
366-
$layouts = collect();
367-
368-
$layoutDirs = $this->getViewPaths('layouts');
369-
370-
foreach ($layoutDirs as $layoutDir) {
371-
if ($layoutFiles = glob($layoutDir . '/{**/*,*}.php', GLOB_BRACE)) {
372-
foreach ($layoutFiles as $layout) {
373-
$layouts->put($layout, basename($layout, '.blade.php'));
374-
}
375-
}
376-
}
377-
378-
return $layouts;
379-
}
380-
381338
/**
382339
* Create public assets directory path.
383340
*/

src/Traits/HasViews.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,49 @@
99

1010
trait HasViews
1111
{
12+
/**
13+
* Get theme views paths.
14+
* Build Paths array.
15+
* All paths are relative to Config::get('themes-manager.directory').
16+
*/
17+
public function getViewPaths(string $path = ''): array
18+
{
19+
$paths = [];
20+
$theme = $this;
21+
22+
do {
23+
$viewsPath = $theme->getPath('resources/views' . ($path ? "/{$path}" : ''));
24+
25+
if (!in_array($viewsPath, $paths)) {
26+
$paths[] = $viewsPath;
27+
}
28+
} while ($theme = $theme->getParent());
29+
30+
return $paths;
31+
}
32+
33+
/**
34+
* List theme's available layouts.
35+
*
36+
* @return \Illuminate\Support\Collection
37+
*/
38+
public function listLayouts()
39+
{
40+
$layouts = collect();
41+
42+
$layoutDirs = $this->getViewPaths('layouts');
43+
44+
foreach ($layoutDirs as $layoutDir) {
45+
if ($layoutFiles = glob($layoutDir . '/{**/*,*}.php', GLOB_BRACE)) {
46+
foreach ($layoutFiles as $layout) {
47+
$layouts->put($layout, basename($layout, '.blade.php'));
48+
}
49+
}
50+
}
51+
52+
return $layouts;
53+
}
54+
1255
/**
1356
* Register theme's views in ViewFinder.
1457
*/

0 commit comments

Comments
 (0)