Fix incompatible signatures after update
This commit is contained in:
parent
134ba508e2
commit
764811c927
8 changed files with 73 additions and 17 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Allocations;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
class StoreAllocationRequest extends ApplicationApiRequest
|
||||
|
@ -16,14 +17,21 @@ class StoreAllocationRequest extends ApplicationApiRequest
|
|||
];
|
||||
}
|
||||
|
||||
public function validated(): array
|
||||
/**
|
||||
* @param string|null $key
|
||||
* @param string|array|null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function validated($key = null, $default = null)
|
||||
{
|
||||
$data = parent::validated();
|
||||
|
||||
return [
|
||||
$response = [
|
||||
'allocation_ip' => $data['ip'],
|
||||
'allocation_ports' => $data['ports'],
|
||||
'allocation_alias' => $data['alias'] ?? null,
|
||||
];
|
||||
|
||||
return is_null($key) ? $response : Arr::get($response, $key, $default);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Nodes;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
|
@ -58,12 +59,18 @@ class StoreNodeRequest extends ApplicationApiRequest
|
|||
* Change the formatting of some data keys in the validated response data
|
||||
* to match what the application expects in the services.
|
||||
*
|
||||
* @return array
|
||||
* @param string|null $key
|
||||
* @param string|array|null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function validated()
|
||||
public function validated($key = null, $default = null)
|
||||
{
|
||||
$response = parent::validated();
|
||||
$response['daemon_base'] = $response['daemon_base'] ?? (new Node())->getAttribute('daemon_base');
|
||||
$response['daemon_base'] = $response['daemon_base'] ?? Node::DEFAULT_DAEMON_BASE;
|
||||
|
||||
if (!is_null($key)) {
|
||||
return Arr::get($response, $key, $default);
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Servers\Databases;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
@ -30,13 +31,20 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest
|
|||
];
|
||||
}
|
||||
|
||||
public function validated(): array
|
||||
/**
|
||||
* @param string|null $key
|
||||
* @param string|array|null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function validated($key = null, $default = null)
|
||||
{
|
||||
return [
|
||||
$data = [
|
||||
'database' => $this->input('database'),
|
||||
'remote' => $this->input('remote'),
|
||||
'database_host_id' => $this->input('host'),
|
||||
];
|
||||
|
||||
return is_null($key) ? $data : Arr::get($data, $key, $default);
|
||||
}
|
||||
|
||||
public function attributes(): array
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
|
@ -43,11 +44,16 @@ class StoreServerRequest extends ApplicationApiRequest
|
|||
];
|
||||
}
|
||||
|
||||
public function validated(): array
|
||||
/**
|
||||
* @param string|null $key
|
||||
* @param string|array|null $default
|
||||
* @return array
|
||||
*/
|
||||
public function validated($key = null, $default = null)
|
||||
{
|
||||
$data = parent::validated();
|
||||
|
||||
return [
|
||||
$response = [
|
||||
'external_id' => array_get($data, 'external_id'),
|
||||
'name' => array_get($data, 'name'),
|
||||
'description' => array_get($data, 'description'),
|
||||
|
@ -76,5 +82,7 @@ class StoreServerRequest extends ApplicationApiRequest
|
|||
'skip_scripts' => array_get($data, 'skip_scripts'),
|
||||
'start_on_completion' => array_get($data, 'start_on_completion', false),
|
||||
];
|
||||
|
||||
return is_null($key) ? $response : Arr::get($response, $key, $default);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
@ -52,9 +53,11 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
|
|||
/**
|
||||
* Convert the allocation field into the expected format for the service handler.
|
||||
*
|
||||
* @return array
|
||||
* @param string|null $key
|
||||
* @param string|array|null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function validated()
|
||||
public function validated($key = null, $default = null)
|
||||
{
|
||||
$data = parent::validated();
|
||||
|
||||
|
@ -73,6 +76,10 @@ class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
|
|||
unset($data['limits']);
|
||||
}
|
||||
|
||||
if (!is_null($key)) {
|
||||
return Arr::get($data, $key, $default);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Pterodactyl\Models\Server;
|
||||
|
||||
class UpdateServerDetailsRequest extends ServerWriteRequest
|
||||
|
@ -24,15 +25,20 @@ class UpdateServerDetailsRequest extends ServerWriteRequest
|
|||
/**
|
||||
* Convert the posted data into the correct format that is expected
|
||||
* by the application.
|
||||
*
|
||||
* @param string|null $key
|
||||
* @param string|array|null $default
|
||||
*/
|
||||
public function validated(): array
|
||||
public function validated($key = null, $default = null)
|
||||
{
|
||||
return [
|
||||
$data = [
|
||||
'external_id' => $this->input('external_id'),
|
||||
'name' => $this->input('name'),
|
||||
'owner_id' => $this->input('user'),
|
||||
'description' => $this->input('description'),
|
||||
];
|
||||
|
||||
return is_null($key) ? $data : Arr::get($data, $key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Requests\Api\Application\Servers;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
|
@ -39,11 +40,15 @@ class UpdateServerRequest extends ApplicationApiRequest
|
|||
];
|
||||
}
|
||||
|
||||
public function validated(): array
|
||||
/**
|
||||
* @param string|null $key
|
||||
* @param string|array|null $default
|
||||
* @return mixed
|
||||
*/
|
||||
public function validated($key = null, $default = null)
|
||||
{
|
||||
$data = parent::validated();
|
||||
|
||||
return [
|
||||
$response = [
|
||||
'external_id' => array_get($data, 'external_id'),
|
||||
'name' => array_get($data, 'name'),
|
||||
'description' => array_get($data, 'description'),
|
||||
|
@ -65,5 +70,7 @@ class UpdateServerRequest extends ApplicationApiRequest
|
|||
'add_allocations' => array_get($data, 'add_allocations'),
|
||||
'remove_allocations' => array_get($data, 'remove_allocations'),
|
||||
];
|
||||
|
||||
return is_null($key) ? $response : Arr::get($response, $key, $default);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,11 @@ class Node extends Model
|
|||
*/
|
||||
public const RESOURCE_NAME = 'node';
|
||||
|
||||
/**
|
||||
* The default location of server files on the Wings instance.
|
||||
*/
|
||||
final public const DEFAULT_DAEMON_BASE = '/var/lib/pterodactyl/volumes';
|
||||
|
||||
public const DAEMON_TOKEN_ID_LENGTH = 16;
|
||||
public const DAEMON_TOKEN_LENGTH = 64;
|
||||
|
||||
|
@ -104,7 +109,7 @@ class Node extends Model
|
|||
'behind_proxy' => false,
|
||||
'memory_overallocate' => 0,
|
||||
'disk_overallocate' => 0,
|
||||
'daemon_base' => '/var/lib/pterodactyl/volumes',
|
||||
'daemon_base' => self::DEFAULT_DAEMON_BASE,
|
||||
'maintenance_mode' => false,
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue