misc_pterodactyl-panel/app/Providers/AppServiceProvider.php
Dane Everitt 08bdc9705f
[L6] Update composer dependencies to support L6
Drops all of the eloquence requirements, this is going to break a shit load of code, needs to happen tired of this package always holding us back.

Quite confident in my ability to write custom code to do the basic validation we need.

Searching should be a fun nightmare to deal with later...
2019-09-04 21:00:34 -07:00

74 lines
2.1 KiB
PHP

<?php
namespace Pterodactyl\Providers;
use View;
use Cache;
use Pterodactyl\Models\User;
use Pterodactyl\Models\Server;
use Pterodactyl\Models\Subuser;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use Pterodactyl\Observers\UserObserver;
use Pterodactyl\Observers\ServerObserver;
use Pterodactyl\Observers\SubuserObserver;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*/
public function boot()
{
Schema::defaultStringLength(191);
User::observe(UserObserver::class);
Server::observe(ServerObserver::class);
Subuser::observe(SubuserObserver::class);
View::share('appVersion', $this->versionData()['version'] ?? 'undefined');
View::share('appIsGit', $this->versionData()['is_git'] ?? false);
}
/**
* Register application service providers.
*/
public function register()
{
// Only load the settings service provider if the environment
// is configured to allow it.
if (! config('pterodactyl.load_environment_only', false) && $this->app->environment() !== 'testing') {
$this->app->register(SettingsServiceProvider::class);
}
}
/**
* Return version information for the footer.
*
* @return array
*/
protected function versionData()
{
return Cache::remember('git-version', 5, function () {
if (file_exists(base_path('.git/HEAD'))) {
$head = explode(' ', file_get_contents(base_path('.git/HEAD')));
if (array_key_exists(1, $head)) {
$path = base_path('.git/' . trim($head[1]));
}
}
if (isset($path) && file_exists($path)) {
return [
'version' => substr(file_get_contents($path), 0, 8),
'is_git' => true,
];
}
return [
'version' => config('app.version'),
'is_git' => false,
];
});
}
}