Skip to content

Commit

Permalink
Merge pull request #70 from hexadog/68-is-child-theme-broken
Browse files Browse the repository at this point in the history
68 is child theme broken
  • Loading branch information
gaetan-hexadog authored Sep 13, 2023
2 parents 76b301f + c13bc29 commit 72c3913
Show file tree
Hide file tree
Showing 8 changed files with 1,149 additions and 554 deletions.
1,672 changes: 1,135 additions & 537 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion helpers/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function page_title(string $title, bool $withAppName = true, string $separator =
/**
* Set theme.
*/
function theme(?string $themeName = null): Hexadog\ThemesManager\Theme
function theme(string $themeName = null): Hexadog\ThemesManager\Theme
{
if ($themeName) {
\Theme::set($themeName);
Expand Down
3 changes: 0 additions & 3 deletions src/Exceptions/ThemeLoaderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

final class ThemeLoaderException extends \RuntimeException
{
/**
* @return \Hexadog\ThemesManager\Exceptions\ThemeLoaderException
*/
public static function duplicate(string $name): self
{
return new self(sprintf(
Expand Down
6 changes: 3 additions & 3 deletions src/Helpers/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Json
/**
* The constructor.
*/
public function __construct(string $path, ?Filesystem $filesystem = null)
public function __construct(string $path, Filesystem $filesystem = null)
{
$this->path = $path;
$this->filesystem = $filesystem ? $filesystem : new Filesystem();
Expand Down Expand Up @@ -103,7 +103,7 @@ public function setPath(string $path): Json
/**
* Make new instance.
*/
public static function make(string $path, ?Filesystem $filesystem = null): Json
public static function make(string $path, Filesystem $filesystem = null): Json
{
return new self($path, $filesystem);
}
Expand Down Expand Up @@ -136,7 +136,7 @@ public function getAttributes(): array
/**
* Convert the given array data to pretty json.
*/
public function toJsonPretty(?array $data = null): false|string
public function toJsonPretty(array $data = null): false|string
{
return json_encode($data ? $data : $this->attributes, JSON_PRETTY_PRINT);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Middleware/ThemeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ThemeLoader
/**
* Handle an incoming request.
*/
public function handle(Request $request, \Closure $next, ?string $theme = null)
public function handle(Request $request, \Closure $next, string $theme = null)
{
// Do not load theme if API request or App is running in console
if ($request->expectsJson() || app()->runningInConsole()) {
Expand Down
8 changes: 4 additions & 4 deletions src/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ public static function make(...$arguments): self
/**
* Get path.
*/
public function getPath(?string $path = null): string
public function getPath(string $path = null): string
{
return $this->path . $path;
}

/**
* Get assets path.
*/
public function getAssetsPath(?string $path = null): string
public function getAssetsPath(string $path = null): string
{
return Config::get('themes-manager.symlink_path', 'themes') . '/' . mb_strtolower($this->vendor) . '/' . mb_strtolower($this->name) . ($path ? '/' . $path : '');
}
Expand Down Expand Up @@ -173,7 +173,7 @@ public function setPath(string $path): self
/**
* Set theme vendor.
*/
public function setVendor(?string $vendor = null): self
public function setVendor(string $vendor = null): self
{
if (Str::contains($vendor, '/')) {
$this->vendor = dirname($vendor);
Expand Down Expand Up @@ -210,7 +210,7 @@ public function setParent(string|Theme|null $theme): self
/**
* Get parent Theme.
*/
public function getParent(): Theme|null
public function getParent(): ?Theme
{
if (is_string($this->parent)) {
$this->parent = ThemesManager::findByName($this->parent);
Expand Down
6 changes: 3 additions & 3 deletions src/ThemesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ public function all(): Collection
/**
* Check if theme with given name exists.
*/
public function has(?string $name = null): bool
public function has(string $name = null): bool
{
return ! is_null($this->findByName($name, null));
}

/**
* Get theme by name (or return all themes if no name given).
*/
public function get(?string $name = null): ?Theme
public function get(string $name = null): ?Theme
{
return $this->findByName($name, null);
}
Expand Down Expand Up @@ -187,7 +187,7 @@ public function url(string $asset, bool $absolute = true): ?string
* If no vendor provided and name not prefixed by vendor
* the first theme with given name is returned.
*/
public function findByName(string $name, ?string $vendor = null): ?Theme
public function findByName(string $name, string $vendor = null): ?Theme
{
// normalize theme name
$name = str_replace(['-theme', 'theme-'], '', $name);
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/HasViews.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ protected function loadViews(): void
$this->assertPublicAssetsPath();

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

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

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

$this->loadVendorViews();
$this->loadMailComponentPaths();
Expand Down

0 comments on commit 72c3913

Please sign in to comment.