Skip to content

Commit 36d0a21

Browse files
Merge pull request #69 from hexadog/68-is-child-theme-broken
68 is child theme broken
2 parents 25e7b5e + c13bc29 commit 36d0a21

File tree

8 files changed

+1149
-554
lines changed

8 files changed

+1149
-554
lines changed

composer.lock

+1,135-537
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helpers/helpers.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function page_title(string $title, bool $withAppName = true, string $separator =
3030
/**
3131
* Set theme.
3232
*/
33-
function theme(?string $themeName = null): Hexadog\ThemesManager\Theme
33+
function theme(string $themeName = null): Hexadog\ThemesManager\Theme
3434
{
3535
if ($themeName) {
3636
\Theme::set($themeName);

src/Exceptions/ThemeLoaderException.php

-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
final class ThemeLoaderException extends \RuntimeException
88
{
9-
/**
10-
* @return \Hexadog\ThemesManager\Exceptions\ThemeLoaderException
11-
*/
129
public static function duplicate(string $name): self
1310
{
1411
return new self(sprintf(

src/Helpers/Json.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class Json
2929
/**
3030
* The constructor.
3131
*/
32-
public function __construct(string $path, ?Filesystem $filesystem = null)
32+
public function __construct(string $path, Filesystem $filesystem = null)
3333
{
3434
$this->path = $path;
3535
$this->filesystem = $filesystem ? $filesystem : new Filesystem();
@@ -103,7 +103,7 @@ public function setPath(string $path): Json
103103
/**
104104
* Make new instance.
105105
*/
106-
public static function make(string $path, ?Filesystem $filesystem = null): Json
106+
public static function make(string $path, Filesystem $filesystem = null): Json
107107
{
108108
return new self($path, $filesystem);
109109
}
@@ -136,7 +136,7 @@ public function getAttributes(): array
136136
/**
137137
* Convert the given array data to pretty json.
138138
*/
139-
public function toJsonPretty(?array $data = null): false|string
139+
public function toJsonPretty(array $data = null): false|string
140140
{
141141
return json_encode($data ? $data : $this->attributes, JSON_PRETTY_PRINT);
142142
}

src/Http/Middleware/ThemeLoader.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ThemeLoader
1212
/**
1313
* Handle an incoming request.
1414
*/
15-
public function handle(Request $request, \Closure $next, ?string $theme = null)
15+
public function handle(Request $request, \Closure $next, string $theme = null)
1616
{
1717
// Do not load theme if API request or App is running in console
1818
if ($request->expectsJson() || app()->runningInConsole()) {

src/Theme.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ public static function make(...$arguments): self
8888
/**
8989
* Get path.
9090
*/
91-
public function getPath(?string $path = null): string
91+
public function getPath(string $path = null): string
9292
{
9393
return $this->path . $path;
9494
}
9595

9696
/**
9797
* Get assets path.
9898
*/
99-
public function getAssetsPath(?string $path = null): string
99+
public function getAssetsPath(string $path = null): string
100100
{
101101
return Config::get('themes-manager.symlink_path', 'themes') . '/' . mb_strtolower($this->vendor) . '/' . mb_strtolower($this->name) . ($path ? '/' . $path : '');
102102
}
@@ -173,7 +173,7 @@ public function setPath(string $path): self
173173
/**
174174
* Set theme vendor.
175175
*/
176-
public function setVendor(?string $vendor = null): self
176+
public function setVendor(string $vendor = null): self
177177
{
178178
if (Str::contains($vendor, '/')) {
179179
$this->vendor = dirname($vendor);
@@ -210,7 +210,7 @@ public function setParent(string|Theme|null $theme): self
210210
/**
211211
* Get parent Theme.
212212
*/
213-
public function getParent(): Theme|null
213+
public function getParent(): ?Theme
214214
{
215215
if (is_string($this->parent)) {
216216
$this->parent = ThemesManager::findByName($this->parent);

src/ThemesManager.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ public function all(): Collection
4242
/**
4343
* Check if theme with given name exists.
4444
*/
45-
public function has(?string $name = null): bool
45+
public function has(string $name = null): bool
4646
{
4747
return ! is_null($this->findByName($name, null));
4848
}
4949

5050
/**
5151
* Get theme by name (or return all themes if no name given).
5252
*/
53-
public function get(?string $name = null): ?Theme
53+
public function get(string $name = null): ?Theme
5454
{
5555
return $this->findByName($name, null);
5656
}
@@ -187,7 +187,7 @@ public function url(string $asset, bool $absolute = true): ?string
187187
* If no vendor provided and name not prefixed by vendor
188188
* the first theme with given name is returned.
189189
*/
190-
public function findByName(string $name, ?string $vendor = null): ?Theme
190+
public function findByName(string $name, string $vendor = null): ?Theme
191191
{
192192
// normalize theme name
193193
$name = str_replace(['-theme', 'theme-'], '', $name);

src/Traits/HasViews.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@ protected function loadViews(): void
6464
$this->assertPublicAssetsPath();
6565

6666
// Register theme views path
67-
$paths = $this->getViewPaths();
67+
$paths = array_reverse($this->getViewPaths());
6868

6969
foreach ($paths as $path) {
7070
View::getFinder()->prependLocation("{$path}");
7171
}
7272

7373
// Update config view.paths to work with errors views
74-
Config::set('view.paths', Arr::prepend(Arr::wrap(Config::get('view.paths')), ...$paths));
74+
Config::set('view.paths', array_merge($paths, Arr::wrap(Config::get('view.paths'))));
7575

7676
$this->loadVendorViews();
7777
$this->loadMailComponentPaths();

0 commit comments

Comments
 (0)