Skip to content

Commit a9976c7

Browse files
committed
[L6] Temporarily hack around theme system to maintain views without having to edit tons of code
1 parent 0d6cf54 commit a9976c7

File tree

5 files changed

+43
-63
lines changed

5 files changed

+43
-63
lines changed

app/Extensions/Facades/Theme.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Pterodactyl\Extensions\Facades;
4+
5+
use Illuminate\Support\Facades\Facade;
6+
7+
class Theme extends Facade
8+
{
9+
/**
10+
* @return string
11+
*/
12+
protected static function getFacadeAccessor()
13+
{
14+
return 'extensions.themes';
15+
}
16+
}

app/Extensions/Themes/Theme.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Pterodactyl\Extensions\Themes;
4+
5+
class Theme
6+
{
7+
public function js($path)
8+
{
9+
return sprintf('<script src="%s"></script>' . PHP_EOL, $this->getUrl($path));
10+
}
11+
12+
public function css($path)
13+
{
14+
return sprintf('<link media="all" type="text/css" rel="stylesheet" href="%s"/>' . PHP_EOL, $this->getUrl($path));
15+
}
16+
17+
protected function getUrl($path)
18+
{
19+
return '/themes/pterodactyl/' . ltrim($path, '/');
20+
}
21+
}

app/Providers/AppServiceProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Support\Facades\Schema;
1111
use Illuminate\Support\ServiceProvider;
1212
use Pterodactyl\Observers\UserObserver;
13+
use Pterodactyl\Extensions\Themes\Theme;
1314
use Pterodactyl\Observers\ServerObserver;
1415
use Pterodactyl\Observers\SubuserObserver;
1516

@@ -40,6 +41,10 @@ public function register()
4041
if (! config('pterodactyl.load_environment_only', false) && $this->app->environment() !== 'testing') {
4142
$this->app->register(SettingsServiceProvider::class);
4243
}
44+
45+
$this->app->singleton('extensions.themes', function () {
46+
return new Theme;
47+
});
4348
}
4449

4550
/**

config/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
'Schema' => Illuminate\Support\Facades\Schema::class,
235235
'Session' => Illuminate\Support\Facades\Session::class,
236236
'Storage' => Illuminate\Support\Facades\Storage::class,
237+
'Theme' => Pterodactyl\Extensions\Facades\Theme::class,
237238
'URL' => Illuminate\Support\Facades\URL::class,
238239
'Validator' => Illuminate\Support\Facades\Validator::class,
239240
'View' => Illuminate\Support\Facades\View::class,

config/themes.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)