2017-08-08 23:24:55 -05:00
|
|
|
<?php
|
|
|
|
|
2017-10-07 16:16:51 -05:00
|
|
|
namespace Pterodactyl\Services\Eggs;
|
2017-08-08 23:24:55 -05:00
|
|
|
|
2017-10-06 23:57:53 -05:00
|
|
|
use Pterodactyl\Models\Egg;
|
2017-10-07 16:16:51 -05:00
|
|
|
use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
|
2017-08-08 23:24:55 -05:00
|
|
|
|
2017-10-07 16:16:51 -05:00
|
|
|
class EggUpdateService
|
2017-08-08 23:24:55 -05:00
|
|
|
{
|
|
|
|
/**
|
2017-08-12 15:29:01 -05:00
|
|
|
* Update a service option.
|
2017-08-08 23:24:55 -05:00
|
|
|
*
|
2022-10-23 17:27:18 -04:00
|
|
|
* @throws NoParentConfigurationFoundException
|
2017-08-08 23:24:55 -05:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function handle(Egg $egg, array $data): void
|
2017-08-08 23:24:55 -05:00
|
|
|
{
|
2022-10-23 17:27:18 -04:00
|
|
|
$eggId = array_get($data, 'config_from');
|
|
|
|
if (!is_null($eggId)) {
|
|
|
|
$results = Egg::query()
|
|
|
|
->where('nest_id', $egg->nest_id)
|
|
|
|
->where('id', $eggId)
|
|
|
|
->count();
|
2017-08-08 23:24:55 -05:00
|
|
|
|
|
|
|
if ($results !== 1) {
|
2017-10-07 16:16:51 -05:00
|
|
|
throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child'));
|
2017-08-08 23:24:55 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-23 17:27:18 -04:00
|
|
|
// TODO: (Dane) Once the admin UI is done being reworked and this is exposed
|
2021-01-10 17:05:41 -08:00
|
|
|
// in said UI, remove this so that you can actually update the denylist.
|
|
|
|
unset($data['file_denylist']);
|
|
|
|
|
2022-10-23 17:27:18 -04:00
|
|
|
$egg->update($data);
|
2017-08-08 23:24:55 -05:00
|
|
|
}
|
|
|
|
}
|