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
|
@ -9,17 +9,11 @@ use Pterodactyl\Services\Servers\ServerConfigurationStructureService;
|
|||
|
||||
class EggConfigurationService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Services\Servers\ServerConfigurationStructureService
|
||||
*/
|
||||
private $configurationStructureService;
|
||||
|
||||
/**
|
||||
* EggConfigurationService constructor.
|
||||
*/
|
||||
public function __construct(ServerConfigurationStructureService $configurationStructureService)
|
||||
public function __construct(private ServerConfigurationStructureService $configurationStructureService)
|
||||
{
|
||||
$this->configurationStructureService = $configurationStructureService;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,10 +35,8 @@ class EggConfigurationService
|
|||
|
||||
/**
|
||||
* Convert the "done" variable into an array if it is not currently one.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function convertStartupToNewFormat(array $startup)
|
||||
protected function convertStartupToNewFormat(array $startup): array
|
||||
{
|
||||
$done = Arr::get($startup, 'done');
|
||||
|
||||
|
@ -85,10 +77,7 @@ class EggConfigurationService
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function replacePlaceholders(Server $server, object $configs)
|
||||
protected function replacePlaceholders(Server $server, object $configs): array
|
||||
{
|
||||
// Get the legacy configuration structure for the server so that we
|
||||
// can property map the egg placeholders to values.
|
||||
|
@ -161,20 +150,15 @@ class EggConfigurationService
|
|||
case 'env.SERVER_PORT':
|
||||
$replace = 'server.build.default.port';
|
||||
break;
|
||||
// By default we don't need to change anything, only if we ended up matching a specific legacy item.
|
||||
default:
|
||||
// By default, we don't need to change anything, only if we ended up matching a specific legacy item.
|
||||
$replace = $key;
|
||||
}
|
||||
|
||||
return str_replace("{{{$key}}}", "{{{$replace}}}", $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
protected function matchAndReplaceKeys($value, array $structure)
|
||||
protected function matchAndReplaceKeys(mixed $value, array $structure): mixed
|
||||
{
|
||||
preg_match_all('/{{(?<key>[\w.-]*)}}/', $value, $matches);
|
||||
|
||||
|
@ -229,12 +213,8 @@ class EggConfigurationService
|
|||
* Iterates over a set of "find" values for a given file in the parser configuration. If
|
||||
* the value of the line match is something iterable, continue iterating, otherwise perform
|
||||
* a match & replace.
|
||||
*
|
||||
* @param mixed $data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function iterate($data, array $structure)
|
||||
private function iterate(mixed $data, array $structure): mixed
|
||||
{
|
||||
if (!is_iterable($data) && !is_object($data)) {
|
||||
return $data;
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Eggs;
|
||||
|
||||
|
@ -18,23 +11,11 @@ use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
|
|||
// When a mommy and a daddy pterodactyl really like each other...
|
||||
class EggCreationService
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* EggCreationService constructor.
|
||||
*/
|
||||
public function __construct(ConfigRepository $config, EggRepositoryInterface $repository)
|
||||
public function __construct(private ConfigRepository $config, private EggRepositoryInterface $repository)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Eggs;
|
||||
|
||||
|
@ -16,25 +9,13 @@ use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
|||
|
||||
class EggDeletionService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
protected $serverRepository;
|
||||
|
||||
/**
|
||||
* EggDeletionService constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ServerRepositoryInterface $serverRepository,
|
||||
EggRepositoryInterface $repository
|
||||
protected ServerRepositoryInterface $serverRepository,
|
||||
protected EggRepositoryInterface $repository
|
||||
) {
|
||||
$this->repository = $repository;
|
||||
$this->serverRepository = $serverRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,7 @@ class EggParserService
|
|||
/**
|
||||
* Takes an uploaded file and parses out the egg configuration from within.
|
||||
*
|
||||
* @throws \JsonException
|
||||
* @throws \Pterodactyl\Exceptions\Service\InvalidFileUploadException
|
||||
*/
|
||||
public function handle(UploadedFile $file): array
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?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
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Eggs;
|
||||
|
||||
|
@ -15,17 +8,11 @@ use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
|
|||
|
||||
class EggUpdateService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* EggUpdateService constructor.
|
||||
*/
|
||||
public function __construct(EggRepositoryInterface $repository)
|
||||
public function __construct(protected EggRepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +22,7 @@ class EggUpdateService
|
|||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
|
||||
*/
|
||||
public function handle(Egg $egg, array $data)
|
||||
public function handle(Egg $egg, array $data): void
|
||||
{
|
||||
if (!is_null(array_get($data, 'config_from'))) {
|
||||
$results = $this->repository->findCountWhere([
|
||||
|
|
|
@ -8,29 +8,21 @@ use Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException;
|
|||
|
||||
class InstallScriptService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* InstallScriptService constructor.
|
||||
*/
|
||||
public function __construct(EggRepositoryInterface $repository)
|
||||
public function __construct(protected EggRepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify the install script for a given Egg.
|
||||
*
|
||||
* @param int|\Pterodactyl\Models\Egg $egg
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException
|
||||
*/
|
||||
public function handle(Egg $egg, array $data)
|
||||
public function handle(Egg $egg, array $data): void
|
||||
{
|
||||
if (!is_null(array_get($data, 'copy_script_from'))) {
|
||||
if (!$this->repository->isCopyableScript(array_get($data, 'copy_script_from'), $egg->nest_id)) {
|
||||
|
|
|
@ -10,17 +10,11 @@ use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
|
|||
|
||||
class EggExporterService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* EggExporterService constructor.
|
||||
*/
|
||||
public function __construct(EggRepositoryInterface $repository)
|
||||
public function __construct(protected EggRepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,7 +32,7 @@ class EggExporterService
|
|||
'version' => Egg::EXPORT_VERSION,
|
||||
'update_url' => $egg->update_url,
|
||||
],
|
||||
'exported_at' => Carbon::now()->toIso8601String(),
|
||||
'exported_at' => Carbon::now()->toAtomString(),
|
||||
'name' => $egg->name,
|
||||
'author' => $egg->author,
|
||||
'description' => $egg->description,
|
||||
|
|
|
@ -13,14 +13,8 @@ use Pterodactyl\Services\Eggs\EggParserService;
|
|||
|
||||
class EggImporterService
|
||||
{
|
||||
protected ConnectionInterface $connection;
|
||||
|
||||
protected EggParserService $parser;
|
||||
|
||||
public function __construct(ConnectionInterface $connection, EggParserService $parser)
|
||||
public function __construct(protected ConnectionInterface $connection, protected EggParserService $parser)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->parser = $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,17 +11,11 @@ use Pterodactyl\Services\Eggs\EggParserService;
|
|||
|
||||
class EggUpdateImporterService
|
||||
{
|
||||
protected ConnectionInterface $connection;
|
||||
|
||||
protected EggParserService $parser;
|
||||
|
||||
/**
|
||||
* EggUpdateImporterService constructor.
|
||||
*/
|
||||
public function __construct(ConnectionInterface $connection, EggParserService $parser)
|
||||
public function __construct(protected ConnectionInterface $connection, protected EggParserService $parser)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->parser = $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace Pterodactyl\Services\Eggs\Variables;
|
||||
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use Illuminate\Contracts\Validation\Factory;
|
||||
use Pterodactyl\Traits\Services\ValidatesValidationRules;
|
||||
use Illuminate\Contracts\Validation\Factory as ValidationFactory;
|
||||
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException;
|
||||
|
||||
|
@ -12,30 +12,18 @@ class VariableCreationService
|
|||
{
|
||||
use ValidatesValidationRules;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Validation\Factory
|
||||
*/
|
||||
private $validator;
|
||||
|
||||
/**
|
||||
* VariableCreationService constructor.
|
||||
*/
|
||||
public function __construct(EggVariableRepositoryInterface $repository, Factory $validator)
|
||||
public function __construct(private EggVariableRepositoryInterface $repository, private ValidationFactory $validator)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the validation factory instance to be used by rule validation
|
||||
* checking in the trait.
|
||||
*/
|
||||
protected function getValidator(): Factory
|
||||
protected function getValidator(): ValidationFactory
|
||||
{
|
||||
return $this->validator;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ namespace Pterodactyl\Services\Eggs\Variables;
|
|||
|
||||
use Illuminate\Support\Str;
|
||||
use Pterodactyl\Models\EggVariable;
|
||||
use Illuminate\Contracts\Validation\Factory;
|
||||
use Pterodactyl\Exceptions\DisplayException;
|
||||
use Pterodactyl\Traits\Services\ValidatesValidationRules;
|
||||
use Illuminate\Contracts\Validation\Factory as ValidationFactory;
|
||||
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
|
||||
use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException;
|
||||
|
||||
|
@ -14,30 +14,18 @@ class VariableUpdateService
|
|||
{
|
||||
use ValidatesValidationRules;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Validation\Factory
|
||||
*/
|
||||
private $validator;
|
||||
|
||||
/**
|
||||
* VariableUpdateService constructor.
|
||||
*/
|
||||
public function __construct(EggVariableRepositoryInterface $repository, Factory $validator)
|
||||
public function __construct(private EggVariableRepositoryInterface $repository, private ValidationFactory $validator)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
$this->validator = $validator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the validation factory instance to be used by rule validation
|
||||
* checking in the trait.
|
||||
*/
|
||||
protected function getValidator(): Factory
|
||||
protected function getValidator(): ValidationFactory
|
||||
{
|
||||
return $this->validator;
|
||||
}
|
||||
|
@ -45,14 +33,12 @@ class VariableUpdateService
|
|||
/**
|
||||
* Update a specific egg variable.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
|
||||
*/
|
||||
public function handle(EggVariable $variable, array $data)
|
||||
public function handle(EggVariable $variable, array $data): mixed
|
||||
{
|
||||
if (!is_null(array_get($data, 'env_variable'))) {
|
||||
if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', EggVariable::RESERVED_ENV_NAMES))) {
|
||||
|
|
Reference in a new issue