From 53190eba192e3e2ae7b14d89aaa21dcc16c85273 Mon Sep 17 00:00:00 2001 From: Gaetan <72258504+gaetan-hexadog@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:47:18 +0200 Subject: [PATCH 1/4] fix(composer): set minimum PHP version required to 7.4 --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 605040c..7d21da4 100755 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ ], "minimum-stability": "stable", "require": { + "php": ">=7.4", "hexadog/laravel-theme-installer": "^1.0", "illuminate/view": "^7.0|^8.0|^9.0|^10.0" }, From e4679a0cea2a87d748357bd78c5bac36780f516a Mon Sep 17 00:00:00 2001 From: Gaetan <72258504+gaetan-hexadog@users.noreply.github.com> Date: Tue, 4 Apr 2023 15:49:03 +0200 Subject: [PATCH 2/4] fix(composer): add missing json PHP extension requirement --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 7d21da4..d246da2 100755 --- a/composer.json +++ b/composer.json @@ -15,6 +15,7 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", + "ext-json": "*", "hexadog/laravel-theme-installer": "^1.0", "illuminate/view": "^7.0|^8.0|^9.0|^10.0" }, From 1fe1d03d94ece4f18c0e8d8d28b9c1c6ee60fa77 Mon Sep 17 00:00:00 2001 From: gaetan-hexadog Date: Sat, 8 Apr 2023 07:02:03 +0000 Subject: [PATCH 3/4] Automatically applied php-cs-fixer changes --- src/Helpers/Json.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Helpers/Json.php b/src/Helpers/Json.php index 538c470..ae2f498 100644 --- a/src/Helpers/Json.php +++ b/src/Helpers/Json.php @@ -201,7 +201,8 @@ public function save(): bool /** * Get the specified attribute from json file. * - * @param null $default + * @param null $default + * @param mixed $key * * @return mixed */ From 2dff43dbcd2b533679335437e6c06aaba7dc479a Mon Sep 17 00:00:00 2001 From: Gaetan <72258504+gaetan-hexadog@users.noreply.github.com> Date: Tue, 25 Apr 2023 13:57:23 +0200 Subject: [PATCH 4/4] fix(view): issue with child theme view paths fix #60 --- src/Theme.php | 43 ----------------------------------------- src/Traits/HasViews.php | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/Theme.php b/src/Theme.php index ae2a3f6..329d22e 100644 --- a/src/Theme.php +++ b/src/Theme.php @@ -99,27 +99,6 @@ 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 : ''); } - /** - * Get theme views paths. - * Build Paths array. - * All paths are relative to Config::get('themes-manager.directory'). - */ - public function getViewPaths(string $path = ''): array - { - $paths = []; - $theme = $this; - - do { - $viewsPath = $theme->getPath('resources/views' . ($path ? "/{$path}" : '')); - - if (!in_array($viewsPath, $paths)) { - $paths[] = $viewsPath; - } - } while ($theme = $theme->getParent()); - - return array_reverse($paths); - } - /** * Set extra data. */ @@ -356,28 +335,6 @@ public function url(string $url, bool $absolute = true): string return ltrim(str_replace('\\', '/', $url)); } - /** - * List theme's available layouts. - * - * @return \Illuminate\Support\Collection - */ - public function listLayouts() - { - $layouts = collect(); - - $layoutDirs = $this->getViewPaths('layouts'); - - foreach ($layoutDirs as $layoutDir) { - if ($layoutFiles = glob($layoutDir . '/{**/*,*}.php', GLOB_BRACE)) { - foreach ($layoutFiles as $layout) { - $layouts->put($layout, basename($layout, '.blade.php')); - } - } - } - - return $layouts; - } - /** * Create public assets directory path. */ diff --git a/src/Traits/HasViews.php b/src/Traits/HasViews.php index afa4537..dfbcfc3 100644 --- a/src/Traits/HasViews.php +++ b/src/Traits/HasViews.php @@ -9,6 +9,49 @@ trait HasViews { + /** + * Get theme views paths. + * Build Paths array. + * All paths are relative to Config::get('themes-manager.directory'). + */ + public function getViewPaths(string $path = ''): array + { + $paths = []; + $theme = $this; + + do { + $viewsPath = $theme->getPath('resources/views' . ($path ? "/{$path}" : '')); + + if (!in_array($viewsPath, $paths)) { + $paths[] = $viewsPath; + } + } while ($theme = $theme->getParent()); + + return $paths; + } + + /** + * List theme's available layouts. + * + * @return \Illuminate\Support\Collection + */ + public function listLayouts() + { + $layouts = collect(); + + $layoutDirs = $this->getViewPaths('layouts'); + + foreach ($layoutDirs as $layoutDir) { + if ($layoutFiles = glob($layoutDir . '/{**/*,*}.php', GLOB_BRACE)) { + foreach ($layoutFiles as $layout) { + $layouts->put($layout, basename($layout, '.blade.php')); + } + } + } + + return $layouts; + } + /** * Register theme's views in ViewFinder. */