Skip to content

Commit 8082e93

Browse files
Merge pull request #22 from hexadog/develop
Develop
2 parents 2b66806 + e0a00f5 commit 8082e93

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

config/config.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,24 @@
1313

1414
/*
1515
|--------------------------------------------------------------------------
16-
| Symbolic path
16+
| Symbolic link path
1717
|--------------------------------------------------------------------------
1818
|
1919
| you can change the public themes path used for assets.
2020
|
2121
*/
2222
'symlink_path' => 'themes',
2323

24+
/*
25+
|--------------------------------------------------------------------------
26+
| Symbolic link relative
27+
|--------------------------------------------------------------------------
28+
|
29+
| Determine if relative symlink should be used instead of absolute one.
30+
|
31+
*/
32+
'symlink_relative' => false,
33+
2434
/*
2535
|--------------------------------------------------------------------------
2636
| Fallback Theme

src/Providers/PackageServiceProvider.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
namespace Hexadog\ThemesManager\Providers;
44

5-
use File;
65
use ReflectionClass;
76
use Illuminate\Support\Str;
87
use Illuminate\Routing\Router;
9-
use Illuminate\Filesystem\Filesystem;
108
use Illuminate\Contracts\View\Factory;
119
use Illuminate\Foundation\AliasLoader;
1210
use Illuminate\Support\ServiceProvider;
@@ -69,12 +67,6 @@ protected function getNormalizedNamespace($prefix = '')
6967
*/
7068
public function boot(Router $router)
7169
{
72-
$publicPath = public_path(config('themes-manager.symlink_path', 'themes'));
73-
74-
if (!File::exists($publicPath)) {
75-
app(Filesystem::class)->makeDirectory($publicPath, 0755);
76-
}
77-
7870
$this->loadViewsFrom($this->getPath('resources/views'), 'themes-manager');
7971
$this->loadViewComponentsAs('theme', [
8072
Image::class,

src/Theme.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,22 @@ protected function cleanPath($path = '')
361361
*/
362362
protected function registerViews()
363363
{
364+
// Create target symlink parent directory if required
365+
$publicPath = public_path(Config::get('themes-manager.symlink_path', 'themes'));
366+
if (!File::exists($publicPath)) {
367+
app(Filesystem::class)->makeDirectory($publicPath, 0755);
368+
}
369+
364370
// Create symlink for public resources if not existing yet
365371
$assetsPath = $this->getPath('public');
366372
$publicAssetsPath = public_path($this->getAssetsPath());
373+
367374
if (!File::exists($publicAssetsPath) && File::exists($assetsPath)) {
368-
app(Filesystem::class)->link($assetsPath, rtrim($publicAssetsPath, DIRECTORY_SEPARATOR));
375+
if (Config::get('themes-manager.symlink_relative', false)) {
376+
app(Filesystem::class)->relativeLink($assetsPath, rtrim($publicAssetsPath, DIRECTORY_SEPARATOR));
377+
} else {
378+
app(Filesystem::class)->link($assetsPath, rtrim($publicAssetsPath, DIRECTORY_SEPARATOR));
379+
}
369380
}
370381

371382
// Register theme views path

0 commit comments

Comments
 (0)