Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
parent
95e15d2c8a
commit
cbcf62086f
573 changed files with 4387 additions and 9411 deletions
|
@ -1,8 +0,0 @@
|
|||
<?php
|
||||
/*
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
|
@ -4,7 +4,7 @@ namespace Pterodactyl\Services\Helpers;
|
|||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Filesystem\FilesystemManager;
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||
|
||||
class AssetHashService
|
||||
{
|
||||
|
@ -13,34 +13,20 @@ class AssetHashService
|
|||
*/
|
||||
public const MANIFEST_PATH = './assets/manifest.json';
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Filesystem\Filesystem
|
||||
*/
|
||||
private $filesystem;
|
||||
private Filesystem $filesystem;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Foundation\Application
|
||||
*/
|
||||
private $application;
|
||||
|
||||
/**
|
||||
* @var array|null
|
||||
*/
|
||||
protected static $manifest;
|
||||
protected static mixed $manifest;
|
||||
|
||||
/**
|
||||
* AssetHashService constructor.
|
||||
*/
|
||||
public function __construct(Application $application, FilesystemManager $filesystem)
|
||||
public function __construct(FilesystemManager $filesystem)
|
||||
{
|
||||
$this->application = $application;
|
||||
$this->filesystem = $filesystem->createLocalDriver(['root' => public_path()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify a URL to append the asset hash.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function url(string $resource): string
|
||||
{
|
||||
|
@ -52,8 +38,6 @@ class AssetHashService
|
|||
|
||||
/**
|
||||
* Return the data integrity hash for a resource.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function integrity(string $resource): string
|
||||
{
|
||||
|
@ -65,8 +49,6 @@ class AssetHashService
|
|||
|
||||
/**
|
||||
* Return a built CSS import using the provided URL.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function css(string $resource): string
|
||||
{
|
||||
|
@ -92,8 +74,6 @@ class AssetHashService
|
|||
|
||||
/**
|
||||
* Return a built JS import using the provided URL.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
public function js(string $resource): string
|
||||
{
|
||||
|
@ -116,8 +96,6 @@ class AssetHashService
|
|||
|
||||
/**
|
||||
* Get the asset manifest and store it in the cache for quicker lookups.
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
*/
|
||||
protected function manifest(): array
|
||||
{
|
||||
|
|
|
@ -13,98 +13,68 @@ class SoftwareVersionService
|
|||
{
|
||||
public const VERSION_CACHE_KEY = 'pterodactyl:versioning_data';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $result;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Cache\Repository
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @var \GuzzleHttp\Client
|
||||
*/
|
||||
protected $client;
|
||||
private static array $result;
|
||||
|
||||
/**
|
||||
* SoftwareVersionService constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
CacheRepository $cache,
|
||||
Client $client
|
||||
protected CacheRepository $cache,
|
||||
protected Client $client
|
||||
) {
|
||||
$this->cache = $cache;
|
||||
$this->client = $client;
|
||||
|
||||
self::$result = $this->cacheVersionData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version of the panel from the CDN servers.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPanel()
|
||||
public function getPanel(): string
|
||||
{
|
||||
return Arr::get(self::$result, 'panel') ?? 'error';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version of the daemon from the CDN servers.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDaemon()
|
||||
public function getDaemon(): string
|
||||
{
|
||||
return Arr::get(self::$result, 'wings') ?? 'error';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL to the discord server.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDiscord()
|
||||
public function getDiscord(): string
|
||||
{
|
||||
return Arr::get(self::$result, 'discord') ?? 'https://pterodactyl.io/discord';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for donations.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDonations()
|
||||
public function getDonations(): string
|
||||
{
|
||||
return Arr::get(self::$result, 'donations') ?? 'https://paypal.me/PterodactylSoftware';
|
||||
return Arr::get(self::$result, 'donations') ?? 'https://github.com/sponsors/matthewpi';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current version of the panel is the latest.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLatestPanel()
|
||||
public function isLatestPanel(): bool
|
||||
{
|
||||
if (config()->get('app.version') === 'canary') {
|
||||
if (config('app.version') === 'canary') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return version_compare(config()->get('app.version'), $this->getPanel()) >= 0;
|
||||
return version_compare(config('app.version'), $this->getPanel()) >= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a passed daemon version string is the latest.
|
||||
*
|
||||
* @param string $version
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isLatestDaemon($version)
|
||||
public function isLatestDaemon(string $version): bool
|
||||
{
|
||||
if ($version === '0.0.0-canary') {
|
||||
if ($version === 'develop') {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -113,21 +83,19 @@ class SoftwareVersionService
|
|||
|
||||
/**
|
||||
* Keeps the versioning cache up-to-date with the latest results from the CDN.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function cacheVersionData()
|
||||
protected function cacheVersionData(): array
|
||||
{
|
||||
return $this->cache->remember(self::VERSION_CACHE_KEY, CarbonImmutable::now()->addMinutes(config()->get('pterodactyl.cdn.cache_time', 60)), function () {
|
||||
return $this->cache->remember(self::VERSION_CACHE_KEY, CarbonImmutable::now()->addMinutes(config('pterodactyl.cdn.cache_time', 60)), function () {
|
||||
try {
|
||||
$response = $this->client->request('GET', config()->get('pterodactyl.cdn.url'));
|
||||
$response = $this->client->request('GET', config('pterodactyl.cdn.url'));
|
||||
|
||||
if ($response->getStatusCode() === 200) {
|
||||
return json_decode($response->getBody(), true);
|
||||
}
|
||||
|
||||
throw new CdnVersionFetchingException();
|
||||
} catch (Exception $exception) {
|
||||
} catch (Exception) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
|
Reference in a new issue