Merge branch 'develop' into feature/react-admin

This commit is contained in:
Matthew Penner 2021-01-23 14:39:23 -07:00
commit 8feb87de7c
532 changed files with 4262 additions and 5622 deletions

View file

@ -30,9 +30,6 @@ class AssetHashService
/**
* AssetHashService constructor.
*
* @param \Illuminate\Contracts\Foundation\Application $application
* @param \Illuminate\Filesystem\FilesystemManager $filesystem
*/
public function __construct(Application $application, FilesystemManager $filesystem)
{
@ -43,9 +40,6 @@ class AssetHashService
/**
* Modify a URL to append the asset hash.
*
* @param string $resource
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function url(string $resource): string
@ -59,9 +53,6 @@ class AssetHashService
/**
* Return the data integrity hash for a resource.
*
* @param string $resource
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function integrity(string $resource): string
@ -75,9 +66,6 @@ class AssetHashService
/**
* Return a built CSS import using the provided URL.
*
* @param string $resource
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function css(string $resource): string
@ -105,9 +93,6 @@ class AssetHashService
/**
* Return a built JS import using the provided URL.
*
* @param string $resource
* @return string
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
public function js(string $resource): string
@ -132,14 +117,13 @@ class AssetHashService
/**
* Get the asset manifest and store it in the cache for quicker lookups.
*
* @return array
*
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
*/
protected function manifest(): array
{
return self::$manifest ?: self::$manifest = json_decode(
$this->filesystem->get(self::MANIFEST_PATH), true
$this->filesystem->get(self::MANIFEST_PATH),
true
);
}
}

View file

@ -6,34 +6,30 @@ use Exception;
use GuzzleHttp\Client;
use Carbon\CarbonImmutable;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Contracts\Cache\Repository as CacheRepository;
use Pterodactyl\Exceptions\Service\Helper\CdnVersionFetchingException;
class SoftwareVersionService
{
const VERSION_CACHE_KEY = 'pterodactyl:versioning_data';
public const VERSION_CACHE_KEY = 'pterodactyl:versioning_data';
/**
* @var array
*/
private static array $result;
private static $result;
/**
* @var \Illuminate\Contracts\Cache\Repository
*/
protected CacheRepository $cache;
protected $cache;
/**
* @var \GuzzleHttp\Client
*/
protected Client $client;
protected $client;
/**
* SoftwareVersionService constructor.
*
* @param \Illuminate\Contracts\Cache\Repository $cache
* @param \GuzzleHttp\Client $client
*/
public function __construct(
CacheRepository $cache,
@ -118,11 +114,11 @@ class SoftwareVersionService
try {
$response = $this->client->request('GET', config()->get('pterodactyl.cdn.url'));
if ($response->getStatusCode() !== 200) {
throw new CdnVersionFetchingException;
if ($response->getStatusCode() === 200) {
return json_decode($response->getBody(), true);
}
return json_decode($response->getBody(), true);
throw new CdnVersionFetchingException();
} catch (Exception $exception) {
return [];
}